:root {
  color-scheme: light;
  --bg: #f6efe4;
  --bg-deep: #eadcca;
  --ink: #2b241d;
  --ink-soft: #5c4f43;
  --accent: #d4552f;
  --accent-2: #2f7f6a;
  --accent-3: #f3b34b;
  --panel: rgba(255, 255, 255, 0.9);
  --border: rgba(43, 36, 29, 0.12);
  --shadow: 0 24px 60px rgba(32, 24, 18, 0.18);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #fff6e9 0%, var(--bg) 45%, var(--bg-deep) 100%);
  padding: 28px 16px 40px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 12% 14%, rgba(212, 85, 47, 0.18), transparent 52%),
    radial-gradient(circle at 78% 8%, rgba(47, 127, 106, 0.2), transparent 48%),
    radial-gradient(circle at 60% 78%, rgba(243, 179, 75, 0.2), transparent 52%);
  pointer-events: none;
  z-index: -2;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(43, 36, 29, 0.07) 1px, transparent 0);
  background-size: 28px 28px;
  opacity: 0.45;
  pointer-events: none;
  z-index: -1;
}

.app {
  max-width: 1160px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 28px;
}

.kicker {
  text-transform: uppercase;
  letter-spacing: 0.32em;
  font-size: 12px;
  color: var(--ink-soft);
  margin: 0 0 8px;
}

header h1 {
  font-family: "Playfair Display", "Times New Roman", serif;
  font-size: clamp(30px, 4vw, 44px);
  margin: 0 0 6px;
}

.subtitle {
  margin: 0;
  color: var(--ink-soft);
  max-width: 540px;
  line-height: 1.6;
}

.stats-badge {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 20px;
  display: grid;
  gap: 6px;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.stats-badge span {
  color: var(--accent);
  margin-left: 6px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.1fr);
  gap: 20px;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px 22px 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel.wide {
  grid-column: 1 / -1;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.helper {
  margin: 0 0 14px;
  color: var(--ink-soft);
  line-height: 1.5;
}

textarea {
  width: 100%;
  min-height: 180px;
  border-radius: 16px;
  border: 1px solid rgba(43, 36, 29, 0.18);
  padding: 14px 16px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
  background: rgba(255, 255, 255, 0.9);
}

textarea:focus,
select:focus,
input:focus,
button:focus {
  outline: 2px solid rgba(212, 85, 47, 0.3);
  outline-offset: 2px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  align-items: center;
}

input[type="file"] {
  border: 1px dashed rgba(43, 36, 29, 0.25);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  color: var(--ink-soft);
}

button {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fffaf5;
  box-shadow: 0 14px 24px rgba(212, 85, 47, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(212, 85, 47, 0.28);
}

button.secondary {
  background: rgba(47, 127, 106, 0.12);
  color: var(--accent-2);
  box-shadow: none;
  border: 1px solid rgba(47, 127, 106, 0.3);
}

button.ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid rgba(43, 36, 29, 0.2);
  box-shadow: none;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.notice {
  margin-top: 10px;
  color: var(--accent);
  font-size: 13px;
  min-height: 18px;
}

.settings-panel {
  margin-top: 16px;
  border-radius: 16px;
  border: 1px dashed rgba(43, 36, 29, 0.2);
  background: rgba(255, 255, 255, 0.7);
  padding: 6px 12px;
}

.settings-panel summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 2px;
}

.settings-panel summary::-webkit-details-marker {
  display: none;
}

.settings-panel summary::after {
  content: "+";
  font-size: 18px;
  line-height: 1;
  color: var(--accent);
}

.settings-panel[open] summary::after {
  content: "-";
}

.settings {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}

.setting.full {
  grid-column: 1 / -1;
}

.setting label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--ink-soft);
}

select,
input[type="number"],
input[type="range"] {
  width: 100%;
  border-radius: 999px;
  border: 1px solid rgba(43, 36, 29, 0.2);
  padding: 8px 12px;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.9);
}

input[type="range"] {
  padding: 0;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-row span {
  min-width: 42px;
  text-align: right;
  color: var(--ink-soft);
  font-weight: 600;
}

.range-row .unit {
  min-width: 28px;
}

.control-panel {
  display: grid;
  gap: 18px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.controls.bottom {
  margin-top: 16px;
}

.tip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.tip-row p {
  margin: 0;
}

button.tiny {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 999px;
  box-shadow: none;
  background: rgba(43, 36, 29, 0.08);
  color: var(--ink-soft);
  border: 1px solid rgba(43, 36, 29, 0.2);
}

.plan-card {
  background: rgba(255, 255, 255, 0.78);
  border-radius: 18px;
  padding: 16px 18px;
  border: 1px solid rgba(43, 36, 29, 0.12);
}

.history-panel {
  display: grid;
  gap: 12px;
}

.history-actions {
  margin-top: 4px;
}

.plan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.plan-head h3 {
  margin: 0;
  font-size: 18px;
}

.plan-meta {
  font-size: 12px;
  color: var(--ink-soft);
}

.sentence-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.sentence-item button {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(43, 36, 29, 0.12);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  padding: 12px 14px;
  border-radius: 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  box-shadow: none;
}

.sentence-item button:hover {
  transform: none;
  box-shadow: 0 8px 18px rgba(43, 36, 29, 0.14);
}

.sentence-index {
  font-weight: 700;
  color: var(--accent);
  font-size: 14px;
}

.sentence-text {
  font-size: 14px;
  line-height: 1.5;
}

.sentence-time {
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.sentence-item.current button {
  border-color: rgba(212, 85, 47, 0.6);
  background: rgba(212, 85, 47, 0.08);
}

.sentence-item.done button {
  opacity: 0.6;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow: auto;
}

.history-item {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(43, 36, 29, 0.12);
  border-radius: 16px;
  padding: 10px 14px;
  display: grid;
  gap: 6px;
}

.history-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}

.history-text {
  font-size: 14px;
  line-height: 1.5;
  flex: 1;
  min-width: 0;
}

.history-meta {
  font-size: 12px;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-remove {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid rgba(43, 36, 29, 0.2);
  padding: 0;
  font-size: 18px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.history-remove:hover {
  background: rgba(43, 36, 29, 0.08);
  transform: none;
  box-shadow: none;
}

.history-empty {
  border: 1px dashed rgba(43, 36, 29, 0.25);
  border-radius: 16px;
  padding: 12px 14px;
  color: var(--ink-soft);
  font-size: 13px;
  background: rgba(255, 255, 255, 0.7);
}

footer {
  color: var(--ink-soft);
  font-size: 13px;
}

.reveal {
  animation: rise 0.6s ease both;
}

.panel:nth-child(2) {
  animation-delay: 0.08s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 940px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .stats-badge {
    border-radius: 18px;
  }
}

@media (max-width: 600px) {
  .stats-badge {
    width: 100%;
  }

  .settings {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
