:root {
  color-scheme: light;
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #111827;
  --muted: #64748b;
  --line: #d9e1ec;
  --accent: #0f766e;
  --accent-2: #1d4ed8;
  --danger: #b91c1c;
  --radius: 8px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  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);
}

button, input, textarea {
  font: inherit;
}

.app-shell {
  max-width: 880px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 14px 14px 28px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 4px 12px;
  background: rgba(238, 242, 247, 0.92);
  backdrop-filter: blur(12px);
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

.topbar p, .hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 12px 0;
}

.compact {
  padding-bottom: 14px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.section-title h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.mark {
  width: 4px;
  height: 18px;
  border-radius: 999px;
  background: var(--accent);
}

.grid {
  display: grid;
  gap: 10px;
}

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

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 118px;
}

input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

input.attention {
  border-color: #b45309;
  background: #fffbeb;
  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.18);
}

.actions, .upload-zone {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 12px;
  min-height: 40px;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.secondary {
  background: #e8eef7;
  color: #172033;
  font-weight: 650;
}

.wide {
  width: 100%;
  margin-top: 10px;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  background: #dfe7f1;
  color: #0f172a;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.templates {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.template-group {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  padding: 10px;
}

.template-group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.template-group-title {
  margin: 0;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 800;
}

.model-tier {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 750;
}

.template-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.template-options button {
  display: grid;
  gap: 4px;
  min-height: 64px;
  text-align: left;
  background: #e8eef7;
  color: #1f2937;
  overflow-wrap: anywhere;
}

.template-options button.selected {
  background: var(--accent-2);
  color: #fff;
}

.template-subtitle {
  color: inherit;
  opacity: 0.78;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 500;
}

.list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  padding: 11px;
}

.item-head {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  align-items: flex-start;
}

.item-title {
  margin: 0;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.35;
}

.meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.tag {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #dbeafe;
  color: #1e3a8a;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.tag.official {
  background: #ccfbf1;
  color: #115e59;
}

.tag.unverified {
  background: #e2e8f0;
  color: #64748b;
  font-size: 11px;
  font-weight: 650;
}

.upload-needed {
  border-color: rgba(180, 83, 9, 0.28);
  background: #fffbeb;
}

.answer {
  white-space: pre-wrap;
  line-height: 1.65;
}

.answer-summary {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  padding: 11px;
}

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

.summary-title {
  margin: 0;
  font-size: 13px;
  font-weight: 750;
}

.confidence {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 8px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 750;
}

.confidence.high {
  background: #dcfce7;
  color: #166534;
}

.confidence.medium {
  background: #fef3c7;
  color: #92400e;
}

.confidence.low {
  background: #fee2e2;
  color: #991b1b;
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 7px;
  padding: 12px;
  max-height: 360px;
  overflow: auto;
}

.report-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.report-links a {
  color: var(--accent-2);
  font-weight: 700;
}

.feedback {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.feedback button {
  background: #f1f5f9;
  color: #334155;
  font-size: 12px;
  padding: 8px 6px;
}

.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 16px;
  max-width: 840px;
  margin: 0 auto;
  padding: 12px 14px;
  background: #0f172a;
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.28);
  font-size: 14px;
}

.hidden {
  display: none !important;
}

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

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

  .panel {
    padding: 14px;
    margin: 10px 0;
  }

  .feedback {
    grid-template-columns: repeat(2, 1fr);
  }

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

  h1 {
    font-size: 21px;
  }
}
