:root {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", sans-serif;
  color: #181714;
  background: #f4f1eb;
  font-synthesis: none;
  --ink: #181714;
  --muted: #75716a;
  --hairline: rgba(42, 37, 29, 0.1);
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --accent: #c75c37;
  --accent-dark: #9d4026;
  --green: #1e765a;
  --shadow: 0 24px 70px rgba(73, 57, 38, 0.1), 0 3px 12px rgba(73, 57, 38, 0.06);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 14% 8%, rgba(255, 255, 255, 0.95), transparent 30rem),
    linear-gradient(155deg, #f8f6f1 0%, #eee9e0 100%);
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
label:has(input:focus-visible) {
  outline: 3px solid rgba(199, 92, 55, 0.28);
  outline-offset: 3px;
}
label:has(select:focus-visible) {
  outline: 3px solid rgba(199, 92, 55, 0.28);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.22;
  pointer-events: none;
}

.ambient-one { top: -12rem; right: -6rem; background: #d98858; }
.ambient-two { bottom: -14rem; left: -10rem; background: #7fa69c; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 0 4vw;
  background: rgba(248, 246, 241, 0.68);
  backdrop-filter: blur(24px) saturate(165%);
  -webkit-backdrop-filter: blur(24px) saturate(165%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, #20201f, #504b44);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 8px 18px rgba(29,26,23,.18);
  font-family: Georgia, serif;
  font-size: 24px;
  font-style: italic;
}

.brand strong { display: block; font-size: 14px; letter-spacing: .01em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.top-actions { display: flex; gap: 8px; }

.quiet-button, .icon-button, .link-button, .copy-button,
.secondary-button, .primary-button, .generate-button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.quiet-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--hairline);
  border-radius: 13px;
  background: rgba(255,255,255,.52);
  color: #4d4943;
  transition: background 160ms ease, transform 100ms ease;
}

.quiet-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.quiet-button:hover { background: rgba(255,255,255,.9); }
.quiet-button:active { transform: scale(.96); }
.system-home { justify-content: center; font-size: 11px; font-weight: 700; }

.shell { width: min(1180px, 92vw); margin: 0 auto; padding: 72px 0 56px; }
.hero { max-width: 810px; margin: 0 auto 46px; text-align: center; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.eyebrow span { width: 18px; height: 1px; background: currentColor; }

.hero h1 {
  margin: 15px 0 20px;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(2.7rem, 7vw, 5.3rem);
  font-weight: 500;
  line-height: .98;
  letter-spacing: -.045em;
}

.hero h1 em { color: var(--accent); font-weight: 400; }
.hero p { max-width: 660px; margin: 0 auto; color: var(--muted); font-size: clamp(15px, 2vw, 18px); line-height: 1.7; }

.steps {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  color: #928d85;
  font-size: 12px;
  font-weight: 600;
}

.steps li span { display: grid; width: 22px; height: 22px; place-items: center; border: 1px solid var(--hairline); border-radius: 50%; }
.steps li.active { color: #fff; background: #23211e; box-shadow: 0 8px 20px rgba(35,33,30,.18); }
.steps li.active span { border-color: rgba(255,255,255,.28); }

.glass-card {
  border: 1px solid rgba(255,255,255,.86);
  border-radius: 28px;
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(135%);
  -webkit-backdrop-filter: blur(24px) saturate(135%);
  box-shadow: var(--shadow);
}

.workspace-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.upload-card { min-width: 0; padding: 25px; }
.card-heading, .result-header, .section-label { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.card-heading > div, .result-header > div:first-child, .section-label > div { display: flex; align-items: center; gap: 10px; }
.number-pill {
  display: inline-grid;
  min-width: 33px;
  height: 26px;
  place-items: center;
  padding: 0 8px;
  border-radius: 9px;
  color: var(--accent-dark);
  background: rgba(199,92,55,.1);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
}

h2, h3, p { margin-top: 0; }
.card-heading h2, .result-header h2, .section-label h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.status-chip {
  padding: 6px 10px;
  border-radius: 999px;
  color: #7b746a;
  background: rgba(82,75,65,.07);
  font-size: 10px;
  font-weight: 700;
}

.status-chip.ready { color: var(--green); background: rgba(30,118,90,.1); }
.status-chip.safe { color: var(--green); background: rgba(30,118,90,.09); }
.card-help { min-height: 42px; margin: 11px 0 16px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.dropzone { display: block; cursor: pointer; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.preview-wrap {
  position: relative;
  display: grid;
  min-height: 330px;
  overflow: hidden;
  place-items: center;
  border: 1.5px dashed rgba(72,65,55,.2);
  border-radius: 21px;
  background:
    linear-gradient(rgba(255,255,255,.18), rgba(255,255,255,.18)),
    repeating-linear-gradient(45deg, rgba(70,62,52,.025) 0 8px, transparent 8px 16px);
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.dropzone:hover .preview-wrap, .dropzone.dragging .preview-wrap { border-color: rgba(199,92,55,.55); background-color: rgba(255,255,255,.55); }
.dropzone:active .preview-wrap { transform: scale(.994); }
.preview-wrap img { display: none; width: 100%; height: 330px; object-fit: contain; background: #e9e5dd; }
.preview-wrap.has-image img { display: block; }
.preview-wrap.has-image .empty-state { display: none; }
.empty-state { display: grid; justify-items: center; gap: 8px; padding: 30px; text-align: center; }
.empty-state strong { font-size: 14px; }
.empty-state small { color: #999289; font-size: 11px; }
.upload-icon {
  display: grid;
  width: 55px;
  height: 55px;
  margin-bottom: 5px;
  place-items: center;
  border-radius: 18px;
  color: var(--accent);
  background: rgba(199,92,55,.1);
}
.upload-icon.portrait-icon { color: var(--green); background: rgba(30,118,90,.09); }
.upload-icon svg { width: 26px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.link-button { padding: 6px 2px; color: var(--accent-dark); background: transparent; font-size: 12px; font-weight: 700; }
.upload-card > .link-button { margin-top: 12px; }
.link-button:hover { text-decoration: underline; }
.hidden { display: none !important; }

.controls-card { margin-top: 22px; padding: 28px; }
.control-block + .control-block { margin-top: 28px; padding-top: 27px; border-top: 1px solid var(--hairline); }
.section-label { justify-content: flex-start; }
.section-label > div { display: block; }
.section-label p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-top: 20px;
  padding: 6px;
  border: 1px solid var(--hairline);
  border-radius: 18px;
  background: rgba(79,72,62,.045);
}

.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label span {
  display: grid;
  min-height: 69px;
  align-content: center;
  gap: 4px;
  padding: 10px 13px;
  border-radius: 13px;
  text-align: center;
  transition: background 160ms ease, box-shadow 160ms ease, transform 100ms ease;
}
.segmented label span:active { transform: scale(.98); }
.segmented label strong { font-size: 13px; }
.segmented label small { color: #8a847b; font-size: 10px; }
.segmented input:checked + span { background: rgba(255,255,255,.92); box-shadow: 0 5px 18px rgba(69,60,50,.09), inset 0 0 0 1px rgba(255,255,255,.9); }
.segmented input:checked + span small { color: var(--accent-dark); }

.truth-note, .warning-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 15px;
  padding: 13px 15px;
  border: 1px solid rgba(183,125,51,.16);
  border-radius: 14px;
  color: #76562f;
  background: rgba(227,178,99,.1);
  font-size: 11px;
  line-height: 1.55;
}
.truth-note svg { flex: 0 0 auto; width: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.transfer-block h3 { margin-bottom: 14px; font-size: 13px; }
.check-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.check-grid label { cursor: pointer; }
.check-grid input { position: absolute; opacity: 0; pointer-events: none; }
.check-grid span {
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--hairline);
  border-radius: 13px;
  color: #736e66;
  background: rgba(255,255,255,.42);
  font-size: 12px;
  font-weight: 600;
  transition: transform 100ms ease, color 160ms ease, border-color 160ms ease, background 160ms ease;
}
.check-grid span:active { transform: scale(.96); }
.check-grid input:checked + span { color: var(--accent-dark); border-color: rgba(199,92,55,.25); background: rgba(199,92,55,.09); }
.notes-field { display: grid; gap: 8px; margin-top: 17px; }
.notes-field > span, .dialog-card label > span { color: #6f6a62; font-size: 11px; font-weight: 700; }
textarea, .dialog-card input, .dialog-card select {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255,255,255,.65);
}
textarea { min-height: 82px; padding: 13px 15px; resize: vertical; line-height: 1.55; }
.action-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 25px; }
.secondary-button, .primary-button, .generate-button {
  display: inline-flex;
  min-height: 47px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 18px;
  border-radius: 15px;
  font-size: 12px;
  font-weight: 750;
  transition: transform 100ms ease, opacity 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.secondary-button { border: 1px solid var(--hairline); background: rgba(255,255,255,.66); }
.primary-button { position: relative; overflow: hidden; color: #fff; background: #282521; box-shadow: 0 9px 22px rgba(40,37,33,.17); }
.generate-button { color: #fff; background: linear-gradient(135deg, #c45b37, #9d3c25); box-shadow: 0 10px 24px rgba(157,60,37,.22); }
.secondary-button svg, .primary-button svg, .generate-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.secondary-button:hover { background: #fff; }
.primary-button:hover, .generate-button:hover { box-shadow: 0 13px 30px rgba(40,37,33,.22); }
.secondary-button:active, .primary-button:active, .generate-button:active { transform: scale(.97); }
button:disabled { cursor: not-allowed; opacity: .42; box-shadow: none; }
.primary-button.loading .button-label { opacity: .22; }
.button-progress { position: absolute; inset: 0; transform: translateX(-105%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.25), transparent); }
.primary-button.loading .button-progress { animation: progress 1.2s linear infinite; }
@keyframes progress { to { transform: translateX(105%); } }

.result-card { margin-top: 22px; padding: 28px; }
.result-header { align-items: center; }
.result-tabs { display: flex; padding: 4px; border-radius: 12px; background: rgba(73,66,57,.055); }
.result-tabs button { min-width: 58px; padding: 8px 12px; border: 0; border-radius: 9px; color: #827b71; background: transparent; cursor: pointer; font-size: 11px; font-weight: 700; }
.result-tabs button.active { color: var(--ink); background: rgba(255,255,255,.88); box-shadow: 0 3px 9px rgba(70,62,53,.08); }
.tab-panel { margin-top: 23px; }
.analysis-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.analysis-item { min-height: 120px; padding: 17px; border: 1px solid var(--hairline); border-radius: 17px; background: rgba(255,255,255,.5); }
.analysis-item span { display: block; margin-bottom: 8px; color: var(--accent-dark); font-size: 10px; font-weight: 800; letter-spacing: .07em; }
.analysis-item p { margin: 0; color: #5f5a53; font-size: 12px; line-height: 1.6; }
.prompt-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; color: #6f6a63; font-size: 11px; font-weight: 700; }
.copy-button { padding: 8px 11px; border-radius: 10px; color: var(--accent-dark); background: rgba(199,92,55,.09); font-size: 11px; font-weight: 700; }
pre { margin: 0; padding: 18px; overflow: auto; white-space: pre-wrap; word-break: break-word; border: 1px solid var(--hairline); border-radius: 16px; color: #3d3933; background: rgba(248,246,241,.7); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.7; }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--muted); font-size: 11px; font-weight: 700; }
details pre { margin-top: 9px; }
.image-panel { text-align: center; }
.generated-placeholder { display: grid; min-height: 320px; place-items: center; border: 1px dashed var(--hairline); border-radius: 18px; color: #9a9389; background: rgba(255,255,255,.32); font-size: 12px; }
#generatedImage { display: none; width: min(100%, 720px); max-height: 80vh; object-fit: contain; border-radius: 20px; box-shadow: var(--shadow); }
#generatedImage.visible { display: inline-block; }
.image-actions { margin-top: 15px; }

footer { display: flex; justify-content: space-between; gap: 24px; width: min(1180px, 92vw); margin: 0 auto; padding: 0 0 34px; color: #928c83; font-size: 10px; line-height: 1.5; }

dialog { width: min(520px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 25px; background: transparent; }
dialog::backdrop { background: rgba(36,32,27,.35); backdrop-filter: blur(9px); }
.dialog-card { padding: 25px; border: 1px solid rgba(255,255,255,.84); border-radius: 25px; background: rgba(250,248,244,.95); box-shadow: 0 30px 100px rgba(35,30,25,.28); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.dialog-heading h2 { margin: 4px 0 0; font-size: 22px; letter-spacing: -.03em; }
.dialog-kicker { color: var(--accent-dark); font-size: 10px; font-weight: 800; letter-spacing: .1em; }
.icon-button { display: grid; width: 35px; height: 35px; place-items: center; border-radius: 50%; color: #686159; background: rgba(72,65,56,.07); font-size: 23px; line-height: 1; }
.privacy-line { margin: 18px 0; padding: 12px 14px; border-radius: 13px; color: #765e3e; background: rgba(221,173,99,.12); font-size: 10px; line-height: 1.55; }
.dialog-card label { display: grid; gap: 7px; margin-top: 13px; }
.dialog-card input, .dialog-card select { min-height: 43px; padding: 0 13px; }
.dialog-card select { width: 100%; border: 1px solid var(--hairline); border-radius: 14px; color: var(--ink); background: rgba(255,255,255,.65); }
.provider-hint { margin: 11px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.history-dialog { min-height: 300px; }
.history-list { display: grid; gap: 9px; max-height: 55vh; margin-top: 18px; overflow: auto; }
.history-empty { display: grid; min-height: 170px; place-items: center; color: #928b81; font-size: 12px; }
.history-item { padding: 14px; border: 1px solid var(--hairline); border-radius: 14px; background: rgba(255,255,255,.58); cursor: pointer; }
.history-item strong { display: block; margin-bottom: 5px; font-size: 12px; }
.history-item small { color: var(--muted); font-size: 10px; }
.danger-link { margin-top: 15px; color: #a84730; }
.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 28px;
  max-width: min(88vw, 480px);
  transform: translate(-50%, 20px);
  padding: 11px 15px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 13px;
  color: #fff;
  background: rgba(31,29,26,.9);
  box-shadow: 0 14px 35px rgba(0,0,0,.2);
  opacity: 0;
  pointer-events: none;
  font-size: 11px;
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 820px) {
  .shell { padding-top: 48px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .check-grid { grid-template-columns: repeat(3, 1fr); }
  .analysis-grid { grid-template-columns: repeat(2, 1fr); }
  .preview-wrap, .preview-wrap img { min-height: 290px; height: 290px; }
}

@media (max-width: 590px) {
  .topbar { min-height: 64px; padding: 0 14px; }
  .brand small, .quiet-button span { display: none; }
  .system-home::before { content: "←"; font-size: 17px; }
  .quiet-button { width: 40px; padding: 0; justify-content: center; }
  .shell { width: min(100% - 24px, 1180px); padding-top: 36px; }
  .hero { margin-bottom: 30px; }
  .hero h1 { font-size: clamp(2.55rem, 13vw, 4rem); }
  .steps { gap: 2px; }
  .steps li { padding: 6px 8px; font-size: 10px; }
  .steps li span { width: 19px; height: 19px; }
  .upload-card, .controls-card, .result-card { padding: 18px; border-radius: 22px; }
  .preview-wrap, .preview-wrap img { min-height: 260px; height: 260px; }
  .segmented { grid-template-columns: 1fr; }
  .segmented label span { min-height: 58px; }
  .check-grid { grid-template-columns: repeat(2, 1fr); }
  .action-row { display: grid; grid-template-columns: 1fr; }
  .secondary-button, .primary-button, .generate-button { width: 100%; }
  .result-header { align-items: flex-start; flex-direction: column; }
  .result-tabs { width: 100%; }
  .result-tabs button { flex: 1; }
  .analysis-grid { grid-template-columns: 1fr; }
  footer { width: calc(100% - 28px); flex-direction: column; gap: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (prefers-contrast: more) {
  .glass-card, .topbar, .dialog-card { background: #fff; border-color: #605a51; backdrop-filter: none; }
  .quiet-button, .secondary-button, .check-grid span { border-color: #605a51; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color: #f1eee9;
    background: #191816;
    --ink: #f1eee9;
    --muted: #aaa39a;
    --hairline: rgba(255,255,255,.11);
    --surface: rgba(40, 38, 34, .76);
    --surface-strong: rgba(44, 42, 38, .94);
    --accent: #e9855e;
    --accent-dark: #f09a77;
    --green: #72b99e;
    --shadow: 0 24px 70px rgba(0,0,0,.28), 0 3px 12px rgba(0,0,0,.18);
  }
  body { background: radial-gradient(circle at 15% 0, #2b2925, transparent 35rem), linear-gradient(155deg, #1c1a18, #12110f); }
  .topbar { background: rgba(26,24,21,.72); box-shadow: 0 1px 0 rgba(255,255,255,.06); }
  .quiet-button, .secondary-button, .segmented input:checked + span, .result-tabs button.active, .check-grid span, .analysis-item, textarea, .dialog-card input, .dialog-card select { background: rgba(255,255,255,.07); }
  .preview-wrap img { background: #171614; }
  .dialog-card { background: rgba(38,36,32,.97); }
  textarea, .dialog-card input, .dialog-card select { color: var(--ink); }
  pre { color: #ded9d2; background: rgba(0,0,0,.16); }
}
