:root {
  --bg: #edf8f9;
  --surface: #ffffff;
  --surface-soft: #f7fcfd;
  --text: #0f2333;
  --muted: #506779;
  --primary: #0f766e;
  --primary-strong: #0b5f5a;
  --border: #d2e2e8;
  --shadow: 0 14px 36px rgba(15, 35, 51, 0.1);
  --radius: 16px;
  --radius-sm: 12px;
  --danger: #b42318;
  --danger-soft: #fef3f2;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Plus Jakarta Sans", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 85% 12%, #fde68a55, transparent 45%),
    radial-gradient(circle at 10% 82%, #99f6e433, transparent 42%),
    linear-gradient(145deg, var(--bg), #dcecf2);
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image: radial-gradient(#102030 0.5px, transparent 0.5px);
  background-size: 4px 4px;
}

.app-shell {
  position: relative;
  max-width: 1220px;
  margin: 0 auto;
  padding: 10px 18px 30px;
  display: grid;
  gap: 14px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 2px 2px 0;
}

.brand-logo {
  display: none;
}

.hero-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 92% 8%, rgba(20, 184, 166, 0.14), transparent 32%),
    linear-gradient(120deg, #ffffff, #eefcff);
  box-shadow: var(--shadow);
  padding: 14px 22px 16px;
}

.hero-top {
  display: none;
}

.reset-link {
  border: none;
  background: transparent;
  padding: 4px 2px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.reset-link:hover {
  color: var(--text);
  text-decoration: underline;
}

h1 {
  margin: 6px 0 10px;
  font-size: clamp(1.7rem, 3.2vw, 2.5rem);
  letter-spacing: -0.02em;
  text-align: center;
}

.hero-logo {
  display: block;
  margin: 0 auto 6px;
  width: min(94%, 950px);
  height: 188px;
  object-fit: contain;
  object-position: center;
}

.subtitle {
  margin: 0;
  max-width: 100%;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
}

.left-pane {
  display: grid;
  gap: 14px;
}

.right-pane {
  position: static;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.controls-card {
  padding: 14px;
}

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

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

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

.field-help {
  margin: 0;
  font-size: 0.78rem;
  color: #5f7687;
}

select,
textarea,
button {
  font: inherit;
}

select,
textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

select {
  padding: 10px;
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 12px;
  min-height: 110px;
  max-height: 320px;
  line-height: 1.45;
}

select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.2);
}

.composer {
  padding: 14px;
  display: grid;
  gap: 8px;
}

.composer-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.composer-label {
  font-weight: 700;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.char-counter {
  font-size: 0.8rem;
  color: var(--muted);
}

.char-counter.is-warning {
  color: #9c6700;
  font-weight: 700;
}

.text-btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: #385767;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
}

.text-btn:hover {
  background: #f2fafc;
}

.input-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.composer-footer {
  display: flex;
  justify-content: flex-end;
}

.details-card {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.details-card.is-hidden {
  display: none;
}

.details-title {
  margin: 0;
  font-size: 0.95rem;
  color: var(--primary-strong);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.details-body {
  display: grid;
  gap: 10px;
}

.details-body .section-card {
  margin-top: 0;
}

.primary-btn,
.ghost-btn,
.copy-actions button,
.error-action {
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.14s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.primary-btn {
  min-width: 200px;
  padding: 12px 16px;
  color: #ebfefc;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}

.primary-btn:hover:not(:disabled),
.copy-actions button:hover {
  transform: translateY(-1px);
}

.primary-btn.is-loading .btn-label::before {
  content: "";
  width: 14px;
  height: 14px;
  display: inline-block;
  margin-right: 8px;
  border: 2px solid rgba(235, 254, 252, 0.45);
  border-top-color: rgba(235, 254, 252, 1);
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}

.ghost-btn {
  padding: 8px 14px;
  border-color: var(--border);
  background: #f7fbfd;
  color: #27485b;
}

.ghost-btn:hover {
  background: #eef8fb;
}

.tabs-card {
  overflow: hidden;
}

.tabs-head {
  display: flex;
  gap: 8px;
  padding: 12px 12px 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab-btn {
  border: 1px solid #bfdce5;
  background: #f3fbfd;
  color: #2d5668;
  border-radius: 999px;
  padding: 8px 12px;
  white-space: nowrap;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
}

.tab-btn.is-active {
  border-color: #80bfcd;
  background: #e6f6fa;
  color: #124c62;
}

.tabs-body {
  padding: 12px;
  max-height: none;
  overflow: visible;
}

.tab-panel {
  display: grid;
  gap: 10px;
}

.tab-panel[hidden] {
  display: none !important;
}

.tab-panel h2 {
  margin: 0;
  font-size: 1rem;
}

.tips-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.45;
}

.tips-list li + li {
  margin-top: 6px;
}

.glossary-search {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.glossary-content {
  display: grid;
  gap: 10px;
}

.glossary-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfeff;
  padding: 10px;
}

.glossary-title {
  margin: 0 0 8px;
  font-size: 0.92rem;
  color: #214d61;
}

.glossary-list {
  margin: 0;
  padding-left: 16px;
  color: var(--muted);
  display: grid;
  gap: 8px;
}

.glossary-list strong {
  color: #1f4253;
}

.glossary-empty {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.glossary-empty.is-hidden {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.chat-window {
  min-height: 50vh;
  max-height: 66vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #f8feff, #f3fafb);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 12px;
  align-content: start;
  box-shadow: var(--shadow);
}

.chat-window.is-hidden {
  display: none;
}

.message {
  width: fit-content;
  max-width: min(74%, 680px);
  border-radius: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  align-self: start;
}

.message.user {
  justify-self: end;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  border-color: #0b6159;
  color: #e8fffc;
}

.message.system {
  justify-self: center;
  text-align: center;
  color: var(--muted);
  background: #f8fafc;
  font-size: 0.88rem;
}

.message.system.thinking {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  width: auto;
  max-width: max-content;
  min-height: auto;
}

.thinking-clock {
  display: inline-block;
  animation: tick 1.4s ease-in-out infinite;
}

.message.assistant {
  justify-self: start;
  width: auto;
  max-width: min(74%, 680px);
  background: #fff;
}

.message-title {
  margin: 0;
  font-size: 0.84rem;
  color: var(--primary-strong);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.assistant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.context-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border: 1px solid #b6d4de;
  background: #f0f9fb;
  color: #285468;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 600;
}

.copy-actions {
  margin: 10px 0 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.copy-actions button {
  padding: 8px 12px;
  color: #e8fffc;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}

.section-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fcfeff;
  padding: 12px;
  margin-top: 10px;
}

.section-title {
  margin: 0 0 8px;
  font-size: 0.94rem;
}

.prompt-block {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #bee4f2;
  border-radius: 10px;
  background: #f2fbff;
  white-space: pre-wrap;
  font-family: "IBM Plex Mono", "Menlo", "Consolas", monospace;
  font-size: 0.84rem;
  line-height: 1.35;
}

.list-block {
  margin: 0;
  padding-left: 18px;
  line-height: 1.45;
}

.error-banner {
  border: 1px solid #fecdca;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.error-banner.is-hidden {
  display: none;
}

.error-text {
  margin: 0;
  font-weight: 600;
}

.error-action {
  padding: 7px 12px;
  background: #fff;
  border-color: #fda29b;
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 300px;
  border: 1px solid #a9d8cf;
  border-radius: 12px;
  background: #ecfdf8;
  color: #0d5f58;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  z-index: 20;
}

.toast.is-hidden {
  display: none;
}

.copy-feedback {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid #9fd7ca;
  border-radius: 12px;
  background: rgba(15, 118, 110, 0.95);
  color: #e8fffc;
  padding: 12px 16px;
  font-weight: 700;
  box-shadow: var(--shadow);
  z-index: 40;
  pointer-events: none;
}

.copy-feedback.is-hidden {
  display: none;
}

.app-footer {
  text-align: center;
  color: #355768;
  font-size: 0.84rem;
  padding-top: 2px;
}

input:disabled,
textarea:disabled,
select:disabled,
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes tick {
  0%,
  100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(18deg);
  }
}

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

  .right-pane {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 10px 12px 24px;
  }

  .top-bar {
    padding-top: 0;
  }

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

  .primary-btn {
    width: 100%;
  }

  .composer-footer {
    justify-content: stretch;
  }

  .tabs-head {
    padding-top: 10px;
  }

  .message {
    max-width: 100%;
  }

  .hero-logo {
    width: min(96%, 600px);
    height: 138px;
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
