:root {
  color-scheme: light;
  --ink: #15181e;
  --muted: #676d79;
  --line: #dfe1e6;
  --line-strong: #c5c9d1;
  --paper: #f5f5f2;
  --surface: #ffffff;
  --soft: #ecece8;
  --blue: #2452c6;
  --blue-dark: #183d99;
  --danger: #a92b2b;
  --success: #216c46;
  --shadow: 0 24px 70px rgb(17 24 39 / 10%);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgb(36 82 198 / 4%) 1px, transparent 1px) 0 0 / 48px 48px,
    var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgb(36 82 198 / 25%);
  outline-offset: 2px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 7px;
  color: var(--blue);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 16px;
  font-weight: 720;
  text-decoration: none;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-primary {
  color: white;
  background: var(--blue);
}

.button-primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

.button-secondary,
.button-quiet {
  border-color: var(--line);
  background: var(--surface);
}

.button-secondary:hover:not(:disabled),
.button-quiet:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--soft);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 370px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px;
}

.login-form {
  display: grid;
  gap: 11px;
}

.login-form-minimal {
  grid-template-columns: 1fr 48px;
  gap: 8px;
}

.login-form label,
.question-form label,
.search-field span {
  font-size: 0.78rem;
  font-weight: 760;
}

.login-form input,
.search-field input,
.question-form textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
}

.login-form input {
  height: 48px;
  padding: 0 14px;
}

.login-submit {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  color: white;
  background: var(--blue);
  font-size: 1.25rem;
  cursor: pointer;
}

.login-submit:hover {
  background: var(--blue-dark);
}

.form-error {
  border-left: 3px solid var(--danger);
  margin: 0 0 12px;
  padding: 8px 11px;
  color: var(--danger);
  background: #fff5f5;
  font-size: 0.86rem;
}

.app-shell {
  min-height: 100vh;
  background: var(--surface);
}

.topbar {
  display: flex;
  min-height: 96px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  padding: 18px 28px;
}

.topbar h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.9;
}

.topbar-actions,
.reader-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.secure-badge {
  color: var(--success);
  font-size: 0.75rem;
  font-weight: 750;
}

.secure-badge::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.workspace {
  display: grid;
  min-height: calc(100vh - 96px);
  grid-template-columns: minmax(255px, 0.75fr) minmax(420px, 1.7fr) minmax(285px, 0.85fr);
}

.library,
.analysis-panel {
  min-width: 0;
  padding: 26px 22px;
  background: #fafaf8;
}

.library {
  border-right: 1px solid var(--line);
}

.analysis-panel {
  border-left: 1px solid var(--line);
}

.panel-heading,
.result-heading,
.reader-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading h2,
.reader-header h2 {
  margin: 0;
  font-size: 1.32rem;
  letter-spacing: -0.025em;
}

.count-badge,
.model-badge {
  display: inline-flex;
  min-width: 30px;
  min-height: 27px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  color: var(--muted);
  background: white;
  font-size: 0.72rem;
  font-weight: 760;
}

.search-field {
  display: grid;
  gap: 8px;
  margin: 25px 0 18px;
}

.search-field input {
  height: 42px;
  padding: 0 12px;
}

.transcript-list {
  display: grid;
  gap: 8px;
}

.transcript-item {
  display: grid;
  width: 100%;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
  background: white;
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.transcript-item:hover,
.transcript-item.is-active {
  border-color: var(--blue);
  box-shadow: 0 5px 20px rgb(36 82 198 / 8%);
}

.transcript-item.is-active {
  background: #f7f9ff;
}

.transcript-date,
.transcript-stats {
  color: var(--muted);
  font-size: 0.68rem;
}

.transcript-snippet {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.list-message,
.history-empty {
  margin: 24px 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.list-message.is-error {
  color: var(--danger);
}

.reader {
  min-width: 0;
  background: var(--surface);
}

.empty-state {
  display: grid;
  min-height: calc(100vh - 96px);
  align-content: center;
  justify-items: center;
  padding: 48px;
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 500;
  letter-spacing: -0.04em;
}

.empty-state p:last-child {
  max-width: 530px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.empty-index {
  margin: 0 0 20px;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.reader-content {
  padding: clamp(25px, 5vw, 64px);
}

.reader-header {
  align-items: flex-end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 22px;
}

.reader-header h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.45rem);
  font-weight: 500;
}

.reader-meta {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.75rem;
}

.reader-actions .button {
  min-height: 36px;
  padding: 0 11px;
  font-size: 0.75rem;
}

.transcript-body {
  max-width: 76ch;
  margin: 36px auto 0;
  white-space: pre-wrap;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.6vw, 1.16rem);
  line-height: 1.82;
}

.analysis-intro {
  margin: 20px 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.analysis-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.analysis-action {
  display: grid;
  min-height: 90px;
  gap: 5px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
  text-align: left;
  cursor: pointer;
}

.analysis-action:hover:not(:disabled) {
  border-color: var(--blue);
}

.analysis-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.analysis-action strong {
  font-size: 0.82rem;
}

.analysis-action span {
  color: var(--muted);
  font-size: 0.69rem;
  line-height: 1.35;
}

.question-form {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 20px;
}

.question-form textarea {
  min-height: 82px;
  resize: vertical;
  padding: 11px;
  line-height: 1.45;
}

.analysis-status {
  min-height: 22px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.analysis-status.is-error {
  color: var(--danger);
}

.analysis-status.is-success {
  color: var(--success);
}

.analysis-status.is-loading::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
  content: "";
}

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

.analysis-result-shell,
.history-section {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.result-heading {
  align-items: center;
}

.result-heading h3 {
  margin: 0;
  font-size: 0.82rem;
}

.text-button {
  border: 0;
  padding: 3px;
  color: var(--blue);
  background: transparent;
  font-size: 0.73rem;
  font-weight: 760;
  cursor: pointer;
}

.analysis-result {
  overflow: visible;
  margin: 16px 0 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1.65;
}

.muted-count {
  color: var(--muted);
  font-size: 0.72rem;
}

.analysis-history {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.history-item strong {
  font-size: 0.75rem;
}

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

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 270px minmax(420px, 1fr);
  }

  .analysis-panel {
    grid-column: 2;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    padding: 18px;
  }

  .secure-badge {
    display: none;
  }

  .button-quiet {
    min-height: 36px;
    padding: 0 10px;
    font-size: 0.72rem;
  }

  .workspace {
    display: block;
  }

  .library,
  .analysis-panel {
    border: 0;
    border-bottom: 1px solid var(--line);
    padding: 24px 18px;
  }

  .transcript-list {
    grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  }

  .empty-state {
    min-height: 55vh;
    padding: 42px 22px;
  }

  .reader-content {
    padding: 30px 20px 50px;
  }

  .reader-header {
    display: grid;
  }

  .analysis-panel {
    border-top: 1px solid var(--line);
  }
}

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