:root {
  --ink: #10262a;
  --ink-soft: #2d4a50;
  --sea: #1b6b72;
  --sea-deep: #11484e;
  --foam: #e7f2f1;
  --paper: #f4f8f7;
  --line: rgba(16, 38, 42, 0.12);
  --gold: #b8893d;
  --shadow: 0 18px 50px rgba(16, 38, 42, 0.12);
  --radius: 22px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Figtree", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: #d7e4e3;
  overflow-x: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 10% 0%, rgba(27, 107, 114, 0.28), transparent 55%),
    radial-gradient(ellipse 55% 45% at 90% 15%, rgba(184, 137, 61, 0.18), transparent 50%),
    linear-gradient(160deg, #d5e5e4 0%, #c7d8d7 45%, #e8efee 100%);
  z-index: -2;
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(16, 38, 42, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 38, 42, 0.03) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 85%);
  animation: drift 18s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-12px, 8px, 0); }
}

.app {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 22px;
  animation: rise 0.7s ease both;
}

.top-actions {
  display: flex;
  flex-direction: column;
  align-items: end;
  gap: 10px;
}

.field-input {
  display: grid;
  gap: 4px;
  text-align: right;
}

.field-input span {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field-input input {
  min-width: 240px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.extra-box {
  display: grid;
  gap: 6px;
  padding: 12px 16px 4px;
  border-bottom: 1px solid var(--line);
}

.extra-box > span:first-child {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.extra-box textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  line-height: 1.5;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
}

.extra-box textarea:focus {
  outline: 2px solid rgba(27, 107, 114, 0.25);
  border-color: rgba(27, 107, 114, 0.45);
}

.extra-hint {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.study-timer {
  margin: 0 16px 8px;
  padding: 14px 16px 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  display: grid;
  gap: 12px;
}

.timer-copy {
  display: grid;
  gap: 2px;
}

.timer-label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--sea);
}

.timer-display {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.6rem);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.timer-display.is-urgent {
  color: #9b3b28;
}

.timer-display.is-done {
  color: var(--sea-deep);
}

.timer-meta {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.timer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.timer-btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  color: #f4fffe;
  background: linear-gradient(145deg, var(--sea), var(--sea-deep));
}

.timer-btn.secondary {
  color: var(--sea-deep);
  background: rgba(27, 107, 114, 0.12);
}

.timer-btn.ghost {
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
}

.timer-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.timer-progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(16, 38, 42, 0.08);
  overflow: hidden;
}

.timer-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sea), var(--gold));
  transition: width 0.2s linear;
}

.timer-progress-bar.is-urgent {
  background: linear-gradient(90deg, #c45b3e, #9b3b28);
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.brand-sub,
.top-meta,
.panel-head p,
.empty-state p {
  margin: 0;
  color: var(--ink-soft);
}

.brand-sub {
  margin-top: 8px;
  font-size: 1rem;
}

.top-meta {
  font-weight: 600;
  text-align: right;
}

.workspace {
  display: grid;
  grid-template-columns: 220px 300px minmax(0, 1fr);
  gap: 16px;
  min-height: calc(100vh - 160px);
}

.panel {
  background: rgba(244, 248, 247, 0.82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  overflow: hidden;
  animation: rise 0.8s ease both;
}

.tasks-panel { animation-delay: 0.05s; }
.samples-panel { animation-delay: 0.12s; }
.response-panel { animation-delay: 0.2s; }

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-head {
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2,
.response-stage h3,
.prompt-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel-head h2 {
  font-size: 1.45rem;
}

.panel-head p {
  margin-top: 4px;
  font-size: 0.92rem;
}

.task-grid {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.task-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  text-align: left;
  padding: 14px 14px 12px;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.task-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(27, 107, 114, 0.35);
  box-shadow: 0 10px 24px rgba(16, 38, 42, 0.08);
}

.task-btn.is-active {
  background: linear-gradient(145deg, var(--sea), var(--sea-deep));
  color: #f4fffe;
  box-shadow: 0 14px 28px rgba(17, 72, 78, 0.28);
}

.task-num {
  display: block;
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1;
}

.task-name {
  display: block;
  margin-top: 6px;
  font-size: 0.86rem;
  opacity: 0.9;
}

.task-count {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.8;
}

.sample-list {
  padding: 12px;
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 230px);
  overflow: auto;
}

.sample-btn {
  appearance: none;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  text-align: left;
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.sample-btn:hover {
  transform: translateX(3px);
  border-color: rgba(27, 107, 114, 0.25);
}

.sample-btn.is-active {
  background: var(--foam);
  border-color: rgba(27, 107, 114, 0.4);
}

.sample-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.sample-status {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
}

.status-saved {
  background: rgba(27, 107, 114, 0.14);
  color: var(--sea-deep);
}

.status-new {
  background: rgba(184, 137, 61, 0.16);
  color: #7a5618;
}

.status-new-pill {
  background: rgba(184, 137, 61, 0.16);
  color: #7a5618;
}

.generate-btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 700;
  color: #f4fffe;
  background: linear-gradient(145deg, var(--sea), var(--sea-deep));
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(17, 72, 78, 0.24);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.generate-btn.secondary {
  color: var(--sea-deep);
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(27, 107, 114, 0.28);
  box-shadow: none;
}

.generate-btn.secondary:hover {
  background: rgba(27, 107, 114, 0.1);
  box-shadow: none;
}

.action-row {
  margin: 0 0 16px;
}

.generate-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(17, 72, 78, 0.28);
}

.generate-btn:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.loading-state {
  gap: 14px;
}

.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid rgba(27, 107, 114, 0.18);
  border-top-color: var(--sea);
  animation: spin 0.9s linear infinite;
  margin: 0 auto;
}

.spinner.small {
  width: 24px;
  height: 24px;
  border-width: 3px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.prompt-images {
  margin: 0 0 16px;
  display: grid;
  gap: 12px;
}

.prompt-images.is-multi {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.prompt-images.loading,
.prompt-images.empty {
  padding: 18px;
  border-radius: 16px;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink-soft);
  text-align: center;
}

.prompt-images.loading {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.prompt-figure {
  margin: 0;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(16, 38, 42, 0.04);
  box-shadow: 0 10px 24px rgba(16, 38, 42, 0.08);
}

.prompt-figure img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  background: #fff;
}

.sample-index {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--sea);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sample-title {
  display: block;
  margin-top: 4px;
  font-size: 0.95rem;
  line-height: 1.35;
}

.response-panel {
  display: flex;
  flex-direction: column;
  min-height: 560px;
}

.response-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.timing-chip {
  flex-shrink: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(184, 137, 61, 0.16);
  color: #7a5618;
  font-size: 0.82rem;
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px 0;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.tab:hover {
  background: rgba(27, 107, 114, 0.08);
}

.tab.is-active {
  background: rgba(27, 107, 114, 0.14);
  color: var(--sea-deep);
}

.response-stage {
  flex: 1;
  padding: 18px 20px 24px;
  overflow: auto;
}

.empty-state {
  padding: 28px 18px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.empty-state.large {
  min-height: 320px;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 10px;
  background:
    radial-gradient(circle at 50% 20%, rgba(27, 107, 114, 0.1), transparent 50%);
  border-radius: 18px;
}

.response-card {
  animation: fadeSwap 0.35s ease both;
}

@keyframes fadeSwap {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.prompt-box {
  margin-bottom: 18px;
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(16, 38, 42, 0.04);
  border: 1px solid var(--line);
}

.prompt-label {
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sea);
}

.prompt-title {
  font-size: 1.2rem;
  line-height: 1.35;
  white-space: pre-wrap;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 18px;
}

.meta-pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.response-body {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.75;
  white-space: pre-wrap;
}

.response-body[dir="rtl"] {
  font-size: 1.15rem;
  line-height: 2;
  text-align: right;
}

.notes-body {
  display: grid;
  gap: 18px;
  color: var(--ink-soft);
}

.notes-section {
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
}

.notes-heading {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--sea-deep);
}

.notes-section p {
  margin: 0;
  line-height: 1.7;
}

.notes-list {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 8px;
}

.notes-list li {
  line-height: 1.65;
}

.notes-list li::marker {
  color: var(--sea);
}

.notes-body strong {
  color: var(--ink);
  font-weight: 700;
}

.notes-body em {
  font-style: italic;
}

.notes-empty {
  margin: 0;
  color: var(--ink-soft);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
  }

  .response-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .app {
    width: min(100% - 20px, 1440px);
    padding-top: 18px;
  }

  .topbar {
    flex-direction: column;
    align-items: start;
  }

  .top-actions {
    width: 100%;
    align-items: stretch;
  }

  .field-input {
    text-align: left;
  }

  .field-input input {
    min-width: 0;
    width: 100%;
  }

  .top-meta {
    text-align: left;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .sample-list {
    max-height: 260px;
  }

  .prompt-images.is-multi {
    grid-template-columns: 1fr;
  }
}
