/* Sighto Design System — match iOS app exactly */
:root {
  --bg: #fcf9f8;
  --bg-card: #fff5f0;
  --container-pink: #f5e6e0;
  --container-grey: #e7ded9;
  --accent: #ff6b8a;
  --deep-rose: #ad2c4e;
  --text: #1b1c1c;
  --text-secondary: #b0a8a4;
  --success: #4caf50;
  --warning: #ffa726;
  --error: #ba1a1a;
  --divider: #d1c4be;
  --glass-stroke: rgba(255, 255, 255, 0.4);
  --radius-card: 20px;
  --radius-btn: 25px;
  --shadow-card: 0 4px 10px rgba(0, 0, 0, 0.03);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: #e8e0dc;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Phone shell on desktop */
#app {
  min-height: 100%;
  max-width: 430px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04), 0 20px 60px rgba(0, 0, 0, 0.12);
}

@media (min-width: 480px) {
  body {
    padding: 24px 0;
    background: linear-gradient(160deg, #e8e0dc, #d4c8c2);
  }
  #app {
    min-height: calc(100vh - 48px);
    border-radius: 28px;
  }
}

.screen {
  display: none;
  min-height: 100%;
  flex-direction: column;
  background: var(--bg);
}

.screen.active {
  display: flex;
}

/* Typography */
.t-title {
  font-size: 26px;
  font-weight: 500;
}
.t-headline {
  font-size: 20px;
  font-weight: 500;
}
.t-body {
  font-size: 15px;
  font-weight: 400;
}
.t-label {
  font-size: 13px;
  font-weight: 400;
}
.t-caption {
  font-size: 11px;
  font-weight: 400;
}

/* Glass / Card */
.glass {
  background: rgba(255, 245, 240, 0.92);
  border-radius: var(--radius-card);
  border: 0.5px solid var(--glass-stroke);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

/* Primary button — iOS PrimaryButton */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: var(--radius-btn);
  background: var(--accent);
  color: var(--container-pink);
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(255, 107, 138, 0.2);
  transition: opacity 0.15s, transform 0.1s;
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  padding: 8px;
}

.btn-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}

.btn-pill.pink {
  background: var(--container-pink);
  color: var(--deep-rose);
}

.btn-pill.accent {
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  padding: 14px 16px;
}

.btn-pill.outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--divider);
}

/* ── Home ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 24px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.brand svg,
.brand .spark {
  color: var(--deep-rose);
  width: 18px;
  height: 18px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: 10px;
}

.welcome {
  padding: 0 24px 20px;
}

.welcome h1 {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 4px;
}

.welcome p {
  font-size: 15px;
  color: var(--text-secondary);
}

.input-block {
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.share-box {
  padding: 12px;
  min-height: 92px;
}

.share-box textarea {
  width: 100%;
  min-height: 68px;
  border: none;
  outline: none;
  resize: vertical;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  line-height: 1.5;
}

.share-box textarea::placeholder {
  color: rgba(176, 168, 164, 0.6);
}

.quota-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

.quota-row button {
  border: none;
  background: none;
  color: var(--deep-rose);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
}

.error-box {
  margin: 12px 24px 0;
  padding: 12px;
  background: rgba(245, 230, 224, 0.5);
  border-radius: 12px;
  font-size: 11px;
  line-height: 1.55;
  color: var(--text);
  display: none;
}

.error-box.show {
  display: block;
}

.error-box .err-top {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.error-box .err-top .warn {
  color: var(--warning);
  flex-shrink: 0;
  margin-top: 1px;
}

.error-box .err-text {
  flex: 1;
  white-space: pre-line;
  color: var(--text);
}

.error-box .err-close {
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.error-box .retry-btn {
  margin-top: 10px;
  display: none;
}

.error-box .retry-btn.show {
  display: inline-flex;
}

.latest-card {
  margin: 16px 24px 0;
  padding: 14px;
  display: none;
  align-items: center;
  gap: 10px;
  width: calc(100% - 48px);
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.latest-card.show {
  display: flex;
}

.latest-card .spark {
  color: var(--deep-rose);
  flex-shrink: 0;
}

.latest-card .title {
  flex: 1;
  font-size: 15px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.latest-card .chev {
  color: var(--text-secondary);
  font-size: 12px;
}

.history-section {
  flex: 1;
  margin-top: 16px;
  padding: 0 0 24px;
  overflow: auto;
}

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  color: var(--text-secondary);
  text-align: center;
}

.history-empty .big-icon {
  font-size: 36px;
  opacity: 0.5;
}

.history-empty p {
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-line;
}

.history-empty button {
  border: none;
  background: none;
  color: var(--deep-rose);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
}

.history-head {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 24px;
}

.history-list {
  list-style: none;
  margin: 0 16px;
  background: var(--bg-card);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 0.5px solid rgba(209, 196, 190, 0.5);
  cursor: pointer;
  background: transparent;
  width: 100%;
  border-left: none;
  border-right: none;
  border-top: none;
  text-align: left;
  font-family: inherit;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.history-item .dot.done {
  background: var(--success);
}
.history-item .dot.error {
  background: var(--warning);
}
.history-item .dot.processing,
.history-item .dot.pending {
  background: var(--warning);
}

.history-item .meta {
  flex: 1;
  min-width: 0;
}

.history-item .meta .ht {
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item .meta .hs {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.history-item .del {
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  padding: 6px;
  flex-shrink: 0;
}

/* ── Analyzing ── */
.analyzing-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  padding: 24px 16px 48px;
}

.ring-wrap {
  width: 160px;
  height: 160px;
  position: relative;
}

.ring-wrap svg {
  width: 160px;
  height: 160px;
  transform: rotate(-90deg);
}

.ring-wrap .ring-bg {
  fill: none;
  stroke: rgba(245, 230, 224, 0.4);
  stroke-width: 6;
}

.ring-wrap .ring-fg {
  fill: none;
  stroke: var(--deep-rose);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 471;
  stroke-dashoffset: 471;
  transition: stroke-dashoffset 0.8s ease;
}

.ring-wrap .pct {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 500;
  color: var(--deep-rose);
}

.analyzing-status {
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
  text-align: center;
}

.analyzing-title {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  max-width: 280px;
  padding: 0 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 16px;
}

/* Race track */
.race {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0 8px;
  width: 100%;
  max-width: 360px;
}

.race-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.race-step .circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(231, 222, 217, 0.4);
  color: var(--text-secondary);
  font-size: 14px;
}

.race-step .circle.done {
  background: var(--success);
  color: #fff;
}

.race-step .circle.current {
  background: var(--deep-rose);
  color: #fff;
}

.race-step .label {
  font-size: 11px;
  color: var(--text-secondary);
}

.race-step .label.current {
  color: var(--deep-rose);
}

.race-line {
  height: 2px;
  width: 28px;
  background: var(--divider);
  margin-top: 19px;
  flex-shrink: 0;
}

.race-line.done {
  background: var(--success);
}
.race-line.current {
  background: rgba(173, 44, 78, 0.3);
}

/* ── Result ── */
.result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px 24px;
}

.result-top .brand {
  font-size: 18px;
}

.result-scroll {
  flex: 1;
  overflow: auto;
  padding: 8px 0 48px;
  -webkit-overflow-scrolling: touch;
}

.report-header {
  padding: 0 24px;
}

.report-header .pill {
  display: inline-block;
  font-size: 11px;
  color: var(--deep-rose);
  background: var(--container-pink);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.report-header h2 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
}

.meta-row {
  display: flex;
  gap: 16px;
  padding: 20px 24px 0;
  font-size: 11px;
  color: var(--text-secondary);
}

.summary-card {
  margin: 24px 24px 0;
  padding: 18px;
}

.summary-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.summary-pill {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(245, 230, 224, 0.6);
}

.summary-pill .k {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.summary-pill .v {
  font-size: 15px;
  font-weight: 600;
  color: var(--deep-rose);
  line-height: 1.3;
}

.summary-pill .v.warm {
  color: var(--warning);
}

.summary-block {
  margin-bottom: 16px;
}

.summary-block:last-child {
  margin-bottom: 0;
}

.summary-block .bt {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.summary-block .bd {
  font-size: 14px;
  line-height: 1.55;
  color: rgba(27, 28, 28, 0.78);
}

.summary-block ul {
  list-style: none;
}

.summary-block li {
  display: flex;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(27, 28, 28, 0.72);
  margin-bottom: 8px;
}

.summary-block li::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(173, 44, 78, 0.45);
  margin-top: 7px;
  flex-shrink: 0;
}

.hero-img {
  margin: 32px 24px 0;
  width: calc(100% - 48px);
  height: 200px;
  object-fit: cover;
  border-radius: 24px;
  display: none;
}

.hero-img.show {
  display: block;
}

/* Markdown sections */
.md-sections {
  padding: 32px 24px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-card {
  padding: 20px;
  background: var(--bg-card);
  border-radius: 20px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.02);
}

.section-card .sh {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.section-card .sh .bar {
  width: 3px;
  height: 18px;
  background: rgba(173, 44, 78, 0.6);
  border-radius: 2px;
  flex-shrink: 0;
}

.section-card .sh h3 {
  font-size: 17px;
  font-weight: 600;
}

.section-card .sb {
  font-size: 15px;
  line-height: 1.7;
  color: rgba(27, 28, 28, 0.82);
}

.section-card .sb h4 {
  font-size: 15px;
  font-weight: 600;
  color: rgba(27, 28, 28, 0.9);
  margin: 14px 0 8px;
}

.section-card .sb p {
  margin-bottom: 12px;
}

.section-card .sb ul,
.section-card .sb ol {
  padding-left: 18px;
  margin-bottom: 12px;
}

.section-card .sb li {
  margin-bottom: 8px;
}

.section-card .sb strong {
  font-weight: 600;
  color: var(--text);
}

.section-card .sb blockquote {
  border-left: 3px solid rgba(173, 44, 78, 0.4);
  padding-left: 14px;
  color: rgba(27, 28, 28, 0.65);
  margin: 10px 0;
}

.section-card .sb code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  color: var(--deep-rose);
  background: rgba(245, 230, 224, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
}

.section-card .sb pre {
  background: rgba(245, 230, 224, 0.4);
  padding: 14px;
  border-radius: 10px;
  overflow: auto;
  margin: 8px 0;
}

.section-card .sb pre code {
  background: none;
  padding: 0;
}

.section-card .sb table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 8px 0;
}

.section-card .sb th,
.section-card .sb td {
  border: 0.5px solid var(--divider);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}

.section-card .sb th {
  background: rgba(245, 230, 224, 0.5);
  font-weight: 500;
}

.bottom-bar {
  padding: 32px 24px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bottom-bar .row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Sheet / Modal */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(27, 28, 28, 0.25);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

.overlay.show {
  display: flex;
}

.sheet {
  width: 100%;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 24px;
  animation: sheet-up 0.28s ease;
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.sheet h3 {
  font-size: 20px;
  font-weight: 500;
  text-align: center;
  margin-bottom: 16px;
}

.sheet .field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.sheet .field input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
}

.sheet .field input::placeholder {
  color: var(--text-secondary);
}

.sheet .cancel {
  display: block;
  width: 100%;
  margin-top: 12px;
  text-align: center;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  padding: 10px;
}

.alert {
  position: absolute;
  inset: 0;
  background: rgba(27, 28, 28, 0.3);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 24px;
}

.alert.show {
  display: flex;
}

.alert-box {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 300px;
  text-align: center;
}

.alert-box p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 8px 0 16px;
  line-height: 1.5;
}

.alert-box .actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.alert-box .actions button {
  padding: 10px;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.alert-box .actions .cancel {
  background: var(--container-grey);
  color: var(--text);
}

.alert-box .actions .danger {
  background: var(--error);
  color: #fff;
}

.loading-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-secondary);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--container-pink);
  border-top-color: var(--deep-rose);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Login gate */
.login-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px 48px;
  text-align: center;
}

.login-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--container-pink);
  color: var(--deep-rose);
  display: grid;
  place-items: center;
  font-size: 18px;
  margin-bottom: 24px;
}

.login-title {
  margin-bottom: 8px;
}

.login-sub {
  color: var(--text-secondary);
  margin-bottom: 48px;
}

.login-field {
  width: 100%;
  max-width: 280px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  text-align: left;
}

.login-field input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
}

.login-btn {
  width: 100%;
  max-width: 280px;
  margin-top: 12px;
}

.login-error {
  min-height: 18px;
  font-size: 11px;
  color: var(--error);
  max-width: 280px;
  white-space: pre-line;
}

.login-foot {
  margin-top: auto;
  padding-top: 40px;
  font-size: 11px;
  color: var(--text-secondary);
}

.site-disclaimer {
  padding: 12px 24px 20px;
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
}
