:root {
  --ink: #17211c;
  --muted: #68736d;
  --paper: #f5f3ed;
  --card: #fffef9;
  --line: #deddd5;
  --green: #1d5a40;
  --green-dark: #13442f;
  --mint: #dce9df;
  --amber: #bb6d24;
  --shadow: 0 22px 60px rgba(29, 46, 36, 0.09);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 78% 7%, rgba(29, 90, 64, .08), transparent 27rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.auth-pending .topbar, .auth-pending .shell,
.auth-locked .topbar, .auth-locked .shell { visibility: hidden; }
.auth-gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 70% 15%, rgba(29, 90, 64, .11), transparent 28rem), var(--paper); }
.auth-card { width: min(420px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); box-shadow: var(--shadow); }
.auth-mark { margin-bottom: 22px; }
.auth-card .eyebrow { margin-bottom: 9px; }
.auth-card h2 { margin: 0 0 8px; font-family: Georgia, "Songti SC", serif; font-size: 38px; font-weight: 500; letter-spacing: -.035em; }
.auth-card > p:not(.eyebrow):not(.auth-error) { margin: 0 0 24px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.auth-card label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 750; }
.auth-card input { width: 100%; height: 50px; padding: 0 14px; border: 1px solid #cbcfc8; border-radius: 10px; outline: none; background: #fff; }
.auth-card input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(29, 90, 64, .11); }
.auth-card .button { width: 100%; min-height: 50px; }
.auth-error { min-height: 20px; margin: 7px 0 5px; color: #a33e27; font-size: 12px; }

.topbar {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1120px) / 2));
  border-bottom: 1px solid rgba(23, 33, 28, .12);
  background: rgba(245, 243, 237, .82);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 11px; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; background: var(--green); font-family: Georgia, serif; font-style: italic; }
.live { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: #2b9a62; box-shadow: 0 0 0 4px rgba(43, 154, 98, .12); }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.logout-button { min-height: 34px; padding: 0 12px; background: transparent; }

.shell { width: min(1120px, calc(100% - 48px)); margin: 0 auto; padding-bottom: 80px; }
.hero { padding: 88px 0 70px; }
.eyebrow, .section-kicker { margin: 0 0 14px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .18em; }
h1 { max-width: 830px; margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(45px, 7vw, 82px); line-height: .98; font-weight: 500; letter-spacing: -.052em; }
h1 span { color: var(--green); }
.hero-copy { max-width: 650px; color: var(--muted); font-size: 17px; line-height: 1.75; margin: 28px 0 38px; }

.search-card { max-width: 850px; padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.search-card label { display: block; margin-bottom: 9px; font-size: 12px; font-weight: 750; }
.search-row { display: flex; gap: 10px; align-items: stretch; }
.search-row textarea { flex: 1; min-width: 0; min-height: 92px; resize: vertical; padding: 14px 16px; border: 1px solid #cbcfc8; border-radius: 11px; outline: none; background: #fff; color: var(--ink); line-height: 1.55; }
.search-row textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(29, 90, 64, .11); }
.search-row .button.primary { min-width: 116px; }
.field-hint { margin: 9px 2px 0; color: #8a918d; font-size: 11px; }
.button { min-height: 42px; padding: 0 17px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fff; font-weight: 700; font-size: 13px; transition: .18s ease; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.button:hover { transform: translateY(-1px); border-color: #b7bcb7; }
.button.primary { min-height: 52px; border-color: var(--green); color: #fff; background: var(--green); }
.button.primary:hover { background: var(--green-dark); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button.disabled { opacity: .45; pointer-events: none; }

.section { margin-top: 30px; padding: 36px 0; border-top: 1px solid rgba(23, 33, 28, .14); }
.section.hidden { display: none; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 24px; }
.section-heading h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 36px; font-weight: 500; letter-spacing: -.035em; }
.section-kicker { margin-bottom: 7px; }
.count-pill { padding: 6px 10px; border-radius: 999px; color: var(--green); background: var(--mint); font-size: 12px; font-weight: 750; }
.section-actions { display: flex; align-items: center; gap: 10px; }
.export-button { min-height: 36px; color: #fff; border-color: var(--green); background: var(--green); }
.export-button:hover { color: #fff; background: var(--green-dark); }

.result-list { display: grid; gap: 10px; }
.bulk-actions { display: flex; align-items: center; gap: 14px; margin: -7px 0 14px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 254, 249, .72); }
.bulk-actions .select-all { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; cursor: pointer; }
.bulk-actions input, .result-check input { accent-color: var(--green); width: 16px; height: 16px; }
.bulk-actions #selectionCount { margin-left: auto; color: var(--muted); font-size: 12px; }
.bulk-actions .button.primary { min-height: 38px; }
.result-row { display: grid; grid-template-columns: 22px 60px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 254, 249, .74); }
.result-check { display: grid; place-items: center; cursor: pointer; }
.app-icon { width: 60px; height: 60px; border-radius: 14px; object-fit: cover; background: #e8e7e0; }
.app-title { margin: 0 0 5px; font-size: 15px; font-weight: 760; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font-size: 12px; }
.app-meta code { color: var(--green); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.library-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.app-card { border: 1px solid var(--line); border-radius: 17px; padding: 20px; background: var(--card); box-shadow: 0 9px 30px rgba(29, 46, 36, .04); }
.card-top { display: flex; gap: 14px; align-items: center; }
.card-top .app-icon { width: 64px; height: 64px; }
.card-copy { min-width: 0; flex: 1; }
.sync-badge { display: inline-flex; margin-top: 7px; padding: 4px 8px; border-radius: 999px; color: var(--amber); background: #fff0dc; font-size: 10px; font-weight: 800; }
.sync-badge.complete { color: var(--green); background: var(--mint); }
.progress { height: 6px; border-radius: 999px; overflow: hidden; margin: 18px 0 8px; background: #e7e6df; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width .35s ease; }
.progress-copy { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.price-summary { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.default-price span, .regions span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.default-price strong { display: block; margin-top: 3px; font-family: Georgia, serif; font-size: 23px; font-weight: 500; }
.regions { text-align: right; }
.regions strong { display: block; margin-top: 4px; font-size: 13px; }
.card-actions { margin-top: 14px; display: flex; justify-content: flex-end; }

.empty-state { border: 1px dashed #c9cbc5; border-radius: 18px; text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state.hidden { display: none; }
.empty-icon { width: 42px; height: 42px; margin: 0 auto 13px; display: grid; place-items: center; border-radius: 50%; background: var(--mint); color: var(--green); font-size: 23px; }
.empty-state h3 { margin: 0 0 6px; color: var(--ink); font-family: Georgia, serif; font-size: 21px; font-weight: 500; }
.empty-state p { margin: 0; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 20; padding: 11px 16px; border-radius: 9px; color: #fff; background: var(--ink); box-shadow: var(--shadow); opacity: 0; transform: translate(-50%, 16px); pointer-events: none; transition: .22s ease; font-size: 13px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.error-box { padding: 18px; border: 1px solid #edc7bc; border-radius: 12px; color: #923e29; background: #fff0eb; font-size: 13px; }

@media (max-width: 760px) {
  .topbar { padding: 0 20px; }
  .shell { width: min(100% - 32px, 1120px); }
  .hero { padding-top: 58px; }
  .search-row { flex-direction: column; }
  .bulk-actions { flex-wrap: wrap; }
  .bulk-actions #selectionCount { margin-left: 0; }
  .bulk-actions .button { margin-left: auto; }
  .library-grid { grid-template-columns: 1fr; }
  .result-row { grid-template-columns: 20px 52px minmax(0, 1fr); }
  .result-row .app-icon { width: 52px; height: 52px; }
  .result-row .button { grid-column: 1 / -1; }
  .live { display: none; }
  .section-actions { align-items: flex-end; flex-direction: column; gap: 7px; }
}
