:root {
  color-scheme: light;
  --page: #eef2f7;
  --app-bg: #f6f8fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #dbe4f0;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --green: #16a34a;
  --green-soft: #ecfdf5;
  --amber: #d97706;
  --amber-soft: #fff7ed;
  font-family:
    "Noto Sans KR",
    "Apple SD Gothic Neo",
    "Malgun Gothic",
    system-ui,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--page);
  color: var(--text);
}

body {
  display: flex;
  justify-content: center;
}

button,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  text-decoration: none;
}

h1,
h2,
p {
  margin: 0;
}

.app-screen {
  position: relative;
  width: min(430px, 100vw);
  min-height: 100dvh;
  overflow: hidden;
  background: var(--app-bg);
  box-shadow: 0 20px 80px rgba(15, 23, 42, 0.18);
}

.status-bar {
  display: none;
  height: max(44px, env(safe-area-inset-top));
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px 0;
  background: var(--surface);
  font-size: 13px;
}

.app-header {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  height: 72px;
  padding: 0 28px 0 18px;
  background: var(--surface);
}

.icon-button {
  display: grid;
  width: 32px;
  height: 40px;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 32px;
  line-height: 1;
}

.app-header h1 {
  font-size: 19px;
  line-height: 1.34;
  letter-spacing: 0;
}

.state-badge {
  min-width: 100px;
  padding: 7px 12px;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  background: var(--green-soft);
  color: #059669;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.state-badge.warning,
.warning-pill {
  border-color: #fed7aa;
  background: var(--amber-soft);
  color: #c2410c;
}

.content-scroll {
  height: calc(100dvh - 72px - 64px);
  min-height: 620px;
  overflow-y: auto;
  padding: 8px 0 18px;
}

.media-card {
  position: relative;
  width: calc(100% - 38px);
  max-width: 392px;
  height: 300px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 24px;
  background: #0f172a;
}

.media-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.media-card.is-dimmed::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.26);
}

.scan-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 92px;
  height: 3px;
  background: #22d3ee;
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.78);
}

.scan-line.lower {
  top: 182px;
}

.media-tabs {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 154px;
  max-width: 154px;
  height: 38px;
  margin: -36px auto 20px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.tab {
  width: 58px;
  height: 28px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.tab.active {
  background: var(--blue);
  color: white;
}

.media-tabs span {
  display: none;
}

.analysis-card,
.extracted-card {
  width: calc(100% - 38px);
  max-width: 392px;
  margin: 0 auto 14px;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.analysis-card {
  padding: 18px 20px 16px;
}

.extracted-card {
  padding: 16px 18px 17px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title h2 {
  font-size: 20px;
  line-height: 1.35;
}

.section-title span {
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.section-title.small h2 {
  font-size: 16px;
}

.section-title.small span {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.detected-box {
  margin: 12px 0;
  padding: 10px 14px;
  border: 1px solid #bae6fd;
  border-radius: 12px;
  background: #f0f9ff;
}

.detected-box strong {
  display: block;
  color: #0369a1;
  font-size: 13px;
  line-height: 1.35;
}

.detected-box p {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.45;
  font-weight: 700;
}

.meter-row {
  display: grid;
  grid-template-columns: 76px 1fr 42px;
  align-items: center;
  gap: 8px;
  min-height: 26px;
}

.meter-row span,
.meter-row strong {
  font-size: 12px;
  line-height: 1.3;
}

.meter-row span {
  color: #334155;
  font-weight: 700;
}

.meter-row strong {
  color: var(--blue);
  text-align: right;
}

.meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.meter.green i {
  background: var(--green);
}

.meter.amber i {
  background: var(--amber);
}

.green-text {
  color: var(--green) !important;
}

.amber-text {
  color: var(--amber) !important;
}

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

.info-grid div {
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}

.info-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.info-grid strong {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  line-height: 1.35;
}

.bottom-actions {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 5;
  display: flex;
  gap: 12px;
  width: min(430px, 100vw);
  height: calc(64px + env(safe-area-inset-bottom));
  padding: 8px 30px calc(8px + env(safe-area-inset-bottom)) 20px;
  transform: translateX(-50%);
  background: var(--surface);
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.06);
}

.primary,
.secondary {
  display: grid;
  min-height: 40px;
  place-items: center;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
}

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

.secondary {
  flex: 0 0 112px;
  border: 1px solid #cbd5e1;
  background: white;
  color: #334155;
}

.recheck-banner {
  width: calc(100% - 58px);
  max-width: 372px;
  margin: -8px auto 12px;
  padding: 8px 14px;
  border: 1px solid #fed7aa;
  border-radius: 999px;
  background: var(--amber-soft);
  color: #c2410c;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.screen-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(15, 23, 42, 0.38);
}

.confirm-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 11;
  width: min(430px, 100vw);
  min-height: calc(288px + env(safe-area-inset-bottom));
  padding: 12px 24px calc(20px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background: var(--surface);
  box-shadow: 0 -18px 40px rgba(15, 23, 42, 0.16);
  transform: translateX(-50%);
}

.sheet-handle {
  width: 62px;
  height: 5px;
  margin: 0 auto 21px;
  border-radius: 999px;
  background: #cbd5e1;
}

.sheet-title-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sheet-title-row span {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 12px;
  background: #fef3c7;
  color: #d97706;
  font-weight: 900;
}

.sheet-title-row h2 {
  font-size: 20px;
  line-height: 1.35;
}

.confirm-sheet p {
  margin-top: 12px;
  color: #475569;
  font-size: 14px;
  line-height: 1.6;
}

.editable-summary {
  display: grid;
  grid-template-columns: 94px 1fr;
  gap: 2px;
  align-items: center;
  margin-top: 16px;
  padding: 13px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #f8fafc;
}

.editable-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.editable-summary strong {
  font-size: 14px;
  line-height: 1.35;
}

.sheet-actions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}

.sheet-actions .secondary {
  flex: 1;
  min-width: 0;
  background: #f1f5f9;
  border: 0;
}

.sheet-actions .primary {
  flex: 1.08;
}

@media (max-width: 430px) {
  body {
    display: block;
    background: var(--app-bg);
  }

  .app-screen {
    width: 100vw;
    box-shadow: none;
  }
}

@media (min-width: 431px) {
  .app-screen {
    margin: 0 auto;
  }
}
