:root {
  --bg: #edf2f8;
  --bg-strong: #e6edf6;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-soft: rgba(247, 250, 255, 0.9);
  --surface-hero: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(243, 247, 253, 0.92));
  --ink: #14212d;
  --muted: #627284;
  --line: rgba(20, 33, 45, 0.09);
  --line-strong: rgba(20, 33, 45, 0.16);
  --accent: #1a73e8;
  --accent-soft: rgba(26, 115, 232, 0.12);
  --signal: #137333;
  --warning: #ea4335;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --shadow-lg: 0 24px 48px rgba(25, 38, 52, 0.12);
  --shadow-md: 0 12px 28px rgba(25, 38, 52, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: "Segoe UI Variable Text", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background:
    radial-gradient(circle at top, rgba(26, 115, 232, 0.14), transparent 32%),
    linear-gradient(180deg, #eef3f9 0%, #eaf0f7 38%, #edf2f8 100%);
}

body::before {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0.18)),
    linear-gradient(180deg, rgba(26, 115, 232, 0.04), transparent 36%);
  content: "";
  pointer-events: none;
}

strong {
  font-weight: 800;
}

.page-shell {
  min-height: 100vh;
  padding: 18px 12px calc(28px + env(safe-area-inset-bottom));
}

.mobile-frame {
  width: min(100%, 430px);
  min-height: calc(100vh - 36px);
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 34px;
  background: linear-gradient(180deg, rgba(249, 251, 255, 0.96), rgba(239, 244, 250, 0.98));
  box-shadow: var(--shadow-lg);
  overflow: clip;
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
  background: rgba(248, 251, 255, 0.9);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(20, 33, 45, 0.06);
}

.app-kicker,
.eyebrow,
.result-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.appbar-copy h1 {
  margin: 0;
  font-family: "Bahnschrift", "Arial Narrow", sans-serif;
  font-size: 1.5rem;
  line-height: 1;
  letter-spacing: 0.06em;
}

.appbar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(26, 115, 232, 0.16);
  background: rgba(255, 255, 255, 0.88);
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 800;
}

.feed {
  display: grid;
  gap: 14px;
  padding: 14px 14px 128px;
}

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

.hero-surface {
  padding: 18px;
  background: var(--surface-hero);
}

.hero-surface h2 {
  margin: 0;
  font-size: 1.42rem;
  line-height: 1.3;
  letter-spacing: -0.03em;
}

.hero-copy,
.action-note,
.progress-copy,
.summary-meta,
.upload-copy,
.upload-file {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.65;
}

.hero-copy {
  margin-top: 10px;
  font-size: 0.9rem;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 0;
}

.section-head-stack {
  display: grid;
  gap: 10px;
}

.section-head h2,
.insight-hero h2,
.metric-card h3,
.result-block h3,
.detail-body h3,
.micro-panel h4 {
  margin: 0;
}

.mini-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
}

.scenario-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 16px 18px 18px;
}

.scenario-list::-webkit-scrollbar {
  display: none;
}

.scenario-chip {
  display: grid;
  gap: 6px;
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface-soft);
  color: var(--ink);
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease;
}

.scenario-chip strong {
  font-size: 1rem;
  line-height: 1.2;
}

.scenario-chip span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.scenario-chip.is-active,
.scenario-chip:hover {
  border-color: rgba(26, 115, 232, 0.24);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(26, 115, 232, 0.06));
  transform: translateY(-1px);
}

.upload-zone {
  display: grid;
  gap: 8px;
  margin: 16px 18px 18px;
  padding: 18px;
  border: 1px dashed rgba(20, 33, 45, 0.18);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(248, 251, 255, 0.98), rgba(241, 246, 252, 0.92));
  cursor: pointer;
}

.quick-upload-surface {
  border-color: rgba(26, 115, 232, 0.18);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(237, 245, 255, 0.96));
}

.upload-zone-compact {
  margin: 12px;
  padding: 14px 16px;
}

.upload-zone-strong {
  gap: 6px;
  border-style: solid;
  border-width: 1.5px;
  border-color: rgba(26, 115, 232, 0.28);
  background: linear-gradient(135deg, rgba(26, 115, 232, 0.1), rgba(255, 255, 255, 0.98) 52%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.96);
}

.upload-zone input {
  display: none;
}

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

.upload-action-card {
  display: grid;
  gap: 6px;
  min-height: 132px;
  padding: 14px;
  border: 1px solid rgba(20, 33, 45, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.upload-action-card:hover {
  transform: translateY(-1px);
  border-color: rgba(26, 115, 232, 0.26);
  background: rgba(255, 255, 255, 0.98);
}

.upload-action-card-camera {
  border-color: rgba(19, 115, 51, 0.2);
  background: linear-gradient(180deg, rgba(19, 115, 51, 0.08), rgba(255, 255, 255, 0.96));
}

.upload-mark {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(26, 115, 232, 0.14);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.upload-title {
  font-size: 1rem;
  font-weight: 800;
}

.upload-file {
  color: var(--signal);
  font-weight: 800;
}

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

.extract-surface,
.history-surface {
  overflow: hidden;
}

.extract-body,
.history-body {
  display: grid;
  gap: 12px;
  padding: 16px 18px 18px;
}

.extract-input {
  width: 100%;
  min-height: 168px;
  resize: vertical;
  padding: 14px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(248, 251, 255, 0.96);
  color: var(--ink);
  font: inherit;
  line-height: 1.6;
}

.extract-input:focus {
  outline: none;
  border-color: rgba(26, 115, 232, 0.42);
  box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.1);
}

.action-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.secondary-button {
  min-height: 44px;
  border: 1px solid rgba(26, 115, 232, 0.18);
  border-radius: 16px;
  background: rgba(26, 115, 232, 0.08);
  color: var(--accent);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.secondary-button-ghost {
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
}

.secondary-button:disabled {
  opacity: 0.58;
  cursor: progress;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
}

.history-card-empty {
  background: rgba(246, 249, 253, 0.94);
}

.history-head,
.history-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.history-head strong,
.history-code {
  font-size: 0.94rem;
  line-height: 1.4;
}

.history-meta,
.history-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.history-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.history-card-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(26, 115, 232, 0.2);
  border-radius: 12px;
  background: rgba(26, 115, 232, 0.08);
  color: var(--accent);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.history-card-button-ghost {
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
}

.history-code {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(19, 115, 51, 0.1);
  color: var(--signal);
  font-weight: 800;
}

.overview-surface {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.insight-hero {
  padding: 20px;
  border-radius: 24px;
  background: linear-gradient(180deg, #1a73e8 0%, #4285f4 100%);
  color: #ffffff;
}

.insight-hero .result-label {
  color: rgba(255, 255, 255, 0.72);
}

.insight-hero h2 {
  font-size: 1.3rem;
}

.summary-emphasis {
  margin: 12px 0 0;
  font-size: 1.06rem;
  line-height: 1.72;
}

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

.metric-card,
.result-block,
.micro-panel,
.detail-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.88);
}

.metric-card {
  min-height: 116px;
  padding: 16px;
}

.metric-card h3 {
  font-size: 1.15rem;
  line-height: 1.35;
}

.compact-list,
.ordered-steps,
.detail-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

.compact-list li,
.ordered-steps li,
.detail-list li,
.result-block p,
.detail-body p,
.detail-card p {
  line-height: 1.7;
}

.pipeline-surface {
  padding: 18px;
}

.result-stack {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.result-block {
  padding: 18px;
  opacity: 0.58;
  transform: translateY(8px);
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.result-block.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.result-block h3 {
  margin-bottom: 10px;
  font-size: 1.05rem;
}

.result-block-emphasis {
  border-color: rgba(26, 115, 232, 0.16);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(26, 115, 232, 0.06));
}

.detail-surface {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.detail-panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  overflow: hidden;
}

.detail-panel summary {
  padding: 16px 18px;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

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

.detail-panel[open] summary {
  border-bottom: 1px solid var(--line);
}

.detail-body {
  padding: 18px;
}

.detail-body h3 {
  margin-bottom: 10px;
  font-size: 1.04rem;
}

.detail-split {
  display: grid;
  gap: 10px;
}

.micro-panel {
  padding: 14px;
  background: rgba(244, 248, 253, 0.9);
}

.micro-panel h4 {
  margin-bottom: 8px;
}

.detail-card-list {
  display: grid;
  gap: 10px;
}

.top-gap {
  margin-top: 12px;
}

.detail-card {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.formula-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: "Consolas", "D2Coding", monospace;
  font-size: 0.82rem;
  font-weight: 700;
}

.mobile-actions {
  position: sticky;
  bottom: 0;
  z-index: 12;
  display: grid;
  gap: 0;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(248, 251, 255, 0), rgba(248, 251, 255, 0.94) 22%, rgba(248, 251, 255, 1) 100%);
  backdrop-filter: blur(18px);
}

.analyze-button {
  width: 100%;
  min-height: 56px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(135deg, #1a73e8 0%, #4285f4 100%);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 16px 28px rgba(26, 115, 232, 0.24);
  cursor: pointer;
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    box-shadow 160ms ease;
}

.analyze-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 20px 34px rgba(26, 115, 232, 0.28);
}

.analyze-button:disabled {
  opacity: 0.72;
  cursor: progress;
  box-shadow: none;
}

@media (min-width: 880px) {
  .page-shell {
    padding: 24px;
  }

  .mobile-frame {
    width: min(100%, 460px);
  }

  .feed {
    gap: 16px;
    padding: 18px 18px 134px;
  }

  .scenario-list {
    grid-template-columns: 1fr;
  }
}

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