:root {
  color-scheme: light;
  --bg: #f7f6f1;
  --panel: #fffdfa;
  --panel-strong: #f0efe7;
  --ink: #191816;
  --muted: #68645d;
  --line: #dad5c8;
  --brand: #0c7c7b;
  --brand-dark: #075b5b;
  --accent: #d84e2f;
  --gold: #b98118;
  --shadow: 0 24px 60px rgba(35, 31, 23, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

a {
  color: inherit;
}

button,
input,
textarea,
select {
  font: inherit;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 20;
  padding: 10px 14px;
  background: var(--ink);
  color: white;
  border-radius: 6px;
}

.skip-link:focus {
  top: 16px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid rgba(25, 24, 22, 0.09);
  background: rgba(247, 246, 241, 0.9);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.locale-select {
  min-width: 132px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(20px, 4vw, 40px);
  padding: clamp(28px, 6vw, 70px) clamp(16px, 4vw, 48px) 22px;
}

.hero-copy {
  max-width: 860px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--brand-dark);
  font-size: 0.9rem;
  font-weight: 700;
}

h1 {
  max-width: 940px;
  margin: 18px 0 14px;
  font-size: clamp(2.5rem, 7vw, 6.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.intro {
  max-width: 760px;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  line-height: 1.55;
}

.tool-shell {
  display: grid;
  grid-template-columns: minmax(340px, 1.1fr) minmax(300px, 0.9fr);
  gap: 18px;
  padding: 16px clamp(16px, 4vw, 48px) 40px;
}

.tool-shell > *,
.side-stack,
.panel {
  min-width: 0;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 1rem;
}

.editor-body {
  padding: 18px;
}

.curve-wrap {
  position: relative;
  width: min(100%, 580px);
  margin: 0 auto;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(25, 24, 22, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(25, 24, 22, 0.06) 1px, transparent 1px),
    #fffefb;
  background-size: 25% 25%;
  touch-action: none;
}

#curve-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.handle {
  cursor: grab;
}

.handle:active {
  cursor: grabbing;
}

.axis-label {
  fill: var(--muted);
  font-size: 11px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.field input,
.duration-row input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}

.field input {
  padding: 9px 8px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.favorite-save-row {
  margin-top: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

.btn.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: white;
}

.btn:hover {
  transform: translateY(-1px);
}

.side-stack {
  display: grid;
  gap: 18px;
}

.preview-stage {
  padding: 18px;
}

.segmented-control {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.segmented-button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  font-weight: 750;
}

.segmented-button.active {
  border-color: var(--brand);
  background: rgba(12, 124, 123, 0.1);
  color: var(--brand-dark);
}

.preview-surface {
  min-height: 150px;
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f1eee5, #fff8e8);
  overflow: hidden;
}

.track {
  position: relative;
  width: 100%;
  height: 76px;
  border-radius: 8px;
  background: linear-gradient(90deg, #e8e4d8, #fff8e8);
  overflow: hidden;
}

.dot {
  position: absolute;
  top: 22px;
  left: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(216, 78, 47, 0.34);
  animation-name: travel;
  animation-duration: var(--duration, 1000ms);
  animation-timing-function: var(--curve, cubic-bezier(.25,.1,.25,1));
  animation-iteration-count: infinite;
  animation-direction: alternate;
}

.demo-button {
  min-width: 140px;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-weight: 800;
  animation: preview-pop var(--duration, 1000ms) var(--curve, cubic-bezier(.25,.1,.25,1)) infinite alternate;
}

.demo-modal {
  width: min(260px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  animation: preview-modal var(--duration, 1000ms) var(--curve, cubic-bezier(.25,.1,.25,1)) infinite alternate;
}

.demo-modal strong,
.demo-toast strong,
.demo-card strong {
  display: block;
  margin-bottom: 6px;
}

.demo-modal span,
.demo-toast span,
.demo-card span {
  color: var(--muted);
  font-size: 0.88rem;
}

.demo-toast {
  width: min(280px, 100%);
  padding: 13px 14px;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 36px rgba(35, 31, 23, 0.13);
  animation: preview-toast var(--duration, 1000ms) var(--curve, cubic-bezier(.25,.1,.25,1)) infinite alternate;
}

.demo-card {
  width: min(300px, 100%);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 32px rgba(35, 31, 23, 0.1);
  animation: preview-card var(--duration, 1000ms) var(--curve, cubic-bezier(.25,.1,.25,1)) infinite alternate;
}

@keyframes travel {
  from { left: 18px; }
  to { left: calc(100% - 50px); }
}

@keyframes preview-pop {
  from { transform: scale(0.92); opacity: 0.72; }
  to { transform: scale(1.05); opacity: 1; }
}

@keyframes preview-modal {
  from { transform: translateY(26px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes preview-toast {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes preview-card {
  from { transform: translateX(-24px) rotate(-1deg); opacity: 0.55; }
  to { transform: translateX(12px) rotate(0deg); opacity: 1; }
}

.duration-row {
  display: grid;
  grid-template-columns: 1fr 78px;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
}

.duration-row input[type="range"] {
  accent-color: var(--brand);
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.preset {
  display: grid;
  gap: 5px;
  min-height: 74px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.preset.active {
  border-color: var(--brand);
  outline: 2px solid rgba(12, 124, 123, 0.16);
}

.preset strong {
  font-size: 0.93rem;
}

.preset span {
  color: var(--muted);
  font-size: 0.8rem;
}

.code-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 12px 0;
  overflow-x: auto;
}

.tab {
  white-space: nowrap;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  font-weight: 750;
}

.tab.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.code-output {
  margin: 12px;
  min-height: 128px;
  padding: 14px;
  border-radius: 8px;
  background: #171613;
  color: #f6f1dc;
  overflow: auto;
  font: 0.9rem/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.library-area {
  padding: 0 12px 12px;
}

.library-area h3 {
  margin: 8px 0 10px;
  font-size: 0.95rem;
}

.favorite-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.favorite-item {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.favorite-item strong {
  font-size: 0.9rem;
}

.favorite-item span {
  color: var(--muted);
  font-size: 0.78rem;
}

textarea {
  min-height: 96px;
  resize: vertical;
  padding: 10px;
}

.content-band {
  padding: 46px clamp(16px, 4vw, 48px);
  border-top: 1px solid var(--line);
}

.content-inner {
  max-width: 980px;
}

.content-inner h2 {
  margin: 0 0 12px;
  font-size: clamp(1.8rem, 4vw, 3.1rem);
  line-height: 1.05;
}

.content-inner p {
  max-width: 760px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.faq {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.faq details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px 16px;
}

.faq summary {
  cursor: pointer;
  font-weight: 800;
}

.faq p {
  margin: 10px 0 0;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 26px clamp(16px, 4vw, 48px);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.95rem;
}

@media (max-width: 960px) {
  .hero,
  .tool-shell {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 640px) {
  .topbar,
  .footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .controls,
  .preset-grid {
    grid-template-columns: 1fr;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }
}
