:root {
  --ink: #0e1116;
  --paper: #f7f5f0;
  --card: #ffffff;
  --line: #e6e2d9;
  --muted: #5b6270;
  --accent: #ff5b2e;
  --accent-dark: #e2461b;
  --success: #0fa37f;
  --star: #ffb400;
  --danger: #c8341b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(14, 17, 22, 0.04), 0 4px 16px rgba(14, 17, 22, 0.05);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.has-tabs { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
a { color: var(--accent-dark); }
h1 { font-size: 1.6rem; line-height: 1.2; letter-spacing: -0.02em; margin: 0.4rem 0 0.6rem; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 0.6rem; letter-spacing: -0.01em; }
h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 0.5rem; }
p { margin: 0.4rem 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.fine { font-size: 0.8rem; color: var(--muted); text-align: center; }
.pre { white-space: pre-wrap; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(247, 245, 240, 0.88); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 750; letter-spacing: -0.02em; }
.biz { color: var(--muted); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.admin-link { margin-left: auto; font-size: 0.85rem; }

.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.stack { display: grid; gap: 12px; }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-head h1, .row-head h2 { margin-bottom: 0.6rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(255, 91, 46, 0.45); outline-offset: 2px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.big { width: 100%; min-height: 52px; font-size: 1.05rem; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #f0c9c0; }
.btn[disabled] { opacity: 0.6; pointer-events: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions .btn.big { flex: 1 1 100%; }
.wrap-row { margin: 12px 0; }
.wrap-row form { display: inline-block; margin: 0 6px 6px 0; }
.inline { display: inline; }

.field { display: grid; gap: 6px; }
.field > span:first-child { font-weight: 600; font-size: 0.92rem; }
input[type="text"], input:not([type]), textarea, select {
  width: 100%; font: inherit; color: var(--ink);
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff;
}
textarea { resize: vertical; min-height: 90px; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.choice { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.choice input { margin-top: 5px; accent-color: var(--accent); }

.flash { padding: 12px 14px; border-radius: 12px; background: #e8f7f2; color: #0b6b54; margin: 10px 0; border: 1px solid #c6ebdf; }
.flash.err { background: #fdecea; color: #8f2412; border-color: #f6cfc7; }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; padding: 14px; border-radius: var(--radius); margin-bottom: 12px; }
.banner.warn { background: #fff3e0; border: 1px solid #ffd9a8; }

.signin { margin-top: 8vh; display: grid; gap: 12px; text-align: center; }
.signin h1 { font-size: 2rem; }

.upload h1 { margin-top: 0; }
.drop { display: block; margin: 12px 0; cursor: pointer; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 132px; border: 2px dashed #f3b39f; border-radius: var(--radius);
  background: linear-gradient(180deg, #fff7f3, #fff);
  color: var(--accent-dark); font-weight: 700; font-size: 1.05rem;
}
.drop-btn svg { fill: none; stroke: currentColor; stroke-width: 1.8; }
.drop:focus-within .drop-btn { outline: 3px solid rgba(255, 91, 46, 0.45); outline-offset: 2px; }
.previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-bottom: 12px; }
.previews:empty { display: none; }
.previews img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.bar { width: 100%; height: 8px; accent-color: var(--accent); margin-top: 8px; }
.upload form { display: grid; gap: 12px; }

.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.q { text-decoration: none; color: var(--ink); display: grid; gap: 4px; min-height: 84px; align-content: start; transition: transform 0.15s ease; }
.q:hover { transform: translateY(-2px); }
.q .muted { font-size: 0.85rem; }

.item { display: grid; gap: 6px; text-decoration: none; color: var(--ink); transition: transform 0.15s ease; }
.item:hover { transform: translateY(-1px); }
.item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.item-body { color: var(--muted); font-size: 0.93rem; overflow-wrap: anywhere; }
.kind { font-weight: 700; font-size: 0.9rem; }
.item.mini { padding: 10px 12px; margin-top: 6px; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; background: #f0ede6; color: var(--muted); white-space: nowrap; }
.s-pending { background: #fff1dc; color: #9a5b00; }
.s-scheduled, .s-publishing { background: #e9efff; color: #2b4db8; }
.s-published, .s-done { background: #e3f6ef; color: #0b7a5f; }
.s-failed { background: #fde5e0; color: #a32a14; margin-left: 6px; }
.s-rejected { background: #efefef; color: #666; }

.stars { color: var(--star); letter-spacing: 1px; }
.stars .off { color: #dcd8cf; }
.review p { overflow-wrap: anywhere; }
.reply { margin-top: 8px; padding: 10px 12px; background: var(--paper); border-radius: 10px; font-size: 0.93rem; }
details summary { list-style: none; display: inline-flex; margin-top: 6px; }
details summary::-webkit-details-marker { display: none; }
details[open] summary { margin-bottom: 10px; }

.photo { margin: 12px 0; }
.photo img { width: 100%; max-height: 420px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }
.diff { display: grid; gap: 10px; margin: 12px 0; }
.diff .after { border-color: #ffc2ad; background: #fffaf7; }
.diff .line { padding: 2px 0; overflow-wrap: anywhere; }

.chat { display: grid; gap: 12px; margin: 12px 0 16px; }
.msg { display: grid; gap: 4px; max-width: 88%; }
.msg.user { justify-self: end; justify-items: end; }
.bubble { padding: 10px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--ink); color: #fff; border-color: var(--ink); border-bottom-right-radius: 6px; }
.msg.assistant .bubble { border-bottom-left-radius: 6px; }
.composer {
  position: sticky; bottom: calc(76px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: flex-end; padding: 10px 0; background: var(--paper);
}
.composer textarea { min-height: 52px; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tiles.three { grid-template-columns: repeat(3, 1fr); }
.tile { display: grid; gap: 2px; }
.tile strong { font-size: 1.9rem; letter-spacing: -0.03em; }
.delta { font-size: 0.8rem; color: var(--muted); }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }
.kw { padding-left: 2.2rem; }
.kw li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.kw li:last-child { border-bottom: 0; }

.score { display: flex; align-items: baseline; gap: 8px; }
.score strong { font-size: 2.4rem; letter-spacing: -0.03em; }
.audit { border-left: 5px solid var(--success); }
.audit.warn { border-left-color: var(--star); }
.audit.bad { border-left-color: var(--danger); }
.copy { font-size: 0.85rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.thumb { margin: 0; }
.thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.danger-zone { margin-top: 24px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.detail { max-width: 340px; overflow-wrap: anywhere; color: var(--muted); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabs a { display: grid; justify-items: center; gap: 2px; padding: 6px 0; text-decoration: none; color: var(--muted); font-size: 0.72rem; font-weight: 600; border-radius: 12px; }
.tabs a svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.on { color: var(--accent-dark); background: #fff3ee; }

@media (min-width: 720px) {
  .wrap { padding: 24px; }
  .diff { grid-template-columns: 1fr 1fr; }
  .quick { grid-template-columns: repeat(4, 1fr); }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .actions .btn.big { flex: 0 1 auto; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
