/* SMM Studio — layout after the user's reference: a dark rounded frame with a labelled sidebar,
   a white rounded canvas, pastel cards per brand, one dark "next step" card.
   On a phone the frame drops away and the sidebar becomes a dark bottom bar. One typeface: Inter. */
:root {
  --page: #e8f0fa;
  --frame: #18181b;
  --canvas: #ffffff;
  --soft: #f4f6f9;          /* panels on the canvas */
  --soft-2: #eceff4;        /* hover, wells */
  --line: #e6e9ef;
  --control: #d5dae2;
  --text: #121316;
  --muted: #5d6270;
  --faint: #6b7080;
  --blue: #3d8ee6;          /* data and focus */
  --blue-soft: #e2effc;
  --blue-btn: #bfe0fc;
  --primary: #121316;
  --positive: #1f8a4c;
  --negative: #c4242a;
  --pill-positive-bg: #dcf5e6; --pill-positive-ink: #14532d;
  --pill-warning-bg: #fdf3d8;  --pill-warning-ink: #8a4b0c;
  --pill-neutral-bg: #eceff4;  --pill-neutral-ink: #3b404c;
  --pill-accent-bg: #e2effc;   --pill-accent-ink: #164b85;

  --font: "Inter", system-ui, sans-serif;
  --r-frame: 30px; --r-canvas: 24px; --r-card: 18px; --r-control: 999px;
  --pad: 32px; --gap: 20px;
  --control-height: 36px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--text); font: 14px/20px var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.only-phone { display: none !important; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100svh - 32px); margin: 16px; background: var(--frame); border-radius: var(--r-frame); padding: 10px 10px 10px 0; }
.rail { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 8px 14px 8px 16px; position: sticky; top: 26px; height: calc(100svh - 52px); }
.rail-logo { width: 48px; height: 48px; border-radius: 14px; background: #f6efd9; color: var(--frame); display: grid; place-items: center; margin: 0 0 24px 2px; flex: none; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.rail-item { position: relative; padding: 0 12px; font: inherit; width: 100%; height: 44px; display: flex; align-items: center; gap: 12px; border: 0; background: transparent; color: #9a9ca5; border-radius: 12px; cursor: pointer; flex: none; text-align: left; transition: color .15s, background-color .15s; }
.rail-item svg { width: 20px; height: 20px; flex: none; }
.rail-item:hover { color: #fff; background: #26262b; }
.rail-item[aria-current="page"] { color: #fff; background: #26262b; }
.rail-item[aria-current="page"]::before { content: ""; position: absolute; left: -16px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: #fff; }
.rail-label { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.rail-group { color: #6f717a; font-size: 12px; padding: 18px 12px 6px; }
.rail-brands { display: flex; flex-direction: column; gap: 4px; overflow: auto; min-height: 0; scrollbar-width: none; }
.rail-brand { padding-left: 8px; height: 46px; }
.rail-brand .mark { width: 30px; height: 30px; font-size: 11px; border-radius: 9px; }
.rail-gap { flex: 1; }
.main { background: var(--canvas); border-radius: var(--r-canvas); min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 22px var(--pad) 0; min-height: 58px; }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: 13px; }
.crumbs a:hover { color: var(--text); }
.crumbs b { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.month-switch { display: flex; align-items: center; gap: 2px; background: var(--soft); border-radius: 999px; padding: 3px; }
.month-switch .btn { height: 30px; width: 30px; }
.month-switch .label { min-width: 120px; text-align: center; font-weight: 500; }
.canvas { padding: 18px var(--pad) var(--pad); min-width: 0; flex: 1; }

/* ---------- type ---------- */
.title-row { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 26px; flex-wrap: wrap; }
.title-row .grow { flex: 1; min-width: 240px; }
h1 { font-size: 32px; line-height: 38px; font-weight: 700; letter-spacing: -0.025em; }
.lede { color: var(--muted); margin-top: 6px; font-size: 15px; line-height: 22px; max-width: 70ch; }
.lede strong { color: var(--text); font-weight: 600; }
h2 { font-size: 20px; line-height: 26px; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 15px; line-height: 21px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; min-height: 36px; }

/* ---------- surfaces ---------- */
.panel { background: var(--soft); border-radius: var(--r-card); }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 0; flex-wrap: wrap; }
.panel-head h2 { font-size: 17px; line-height: 24px; }
.panel-head .grow { flex: 1; min-width: 0; }
.panel-body { padding: 16px 20px 20px; }
.stack { display: grid; gap: var(--gap); align-content: start; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--control-height); padding: 0 16px; border-radius: var(--r-control); border: 1px solid var(--control); background: var(--canvas); font-weight: 500; cursor: pointer; white-space: nowrap; transition: background-color .15s, transform .12s var(--ease-out); }
.btn:hover { background: var(--soft-2); }
.btn:active { transform: scale(.97); }
.btn.primary, .btn.dark { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover, .btn.dark:hover { background: #33353b; }
.btn.light { background: var(--blue-btn); border-color: var(--blue-btn); color: var(--text); }
.btn.light:hover { background: #a9d4fb; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--soft-2); color: var(--text); }
.btn.danger { color: var(--negative); }
.btn.lg { height: 44px; padding: 0 20px; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn svg { width: 16px; height: 16px; flex: none; }
.icon-btn { width: var(--control-height); padding: 0; }

label.field { display: grid; gap: 8px; }
.field > span { font-weight: 500; }
.field > small { color: var(--muted); font-size: 12px; line-height: 16px; margin-top: -4px; }
input[type=text], input[type=url], input[type=password], input[type=number], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--canvas); padding: 0 14px; height: 44px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { padding: 11px 14px; height: auto; min-height: 88px; resize: vertical; line-height: 21px; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
::placeholder { color: var(--faint); }
.form-grid { display: grid; gap: 16px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.seg { display: inline-flex; background: var(--soft-2); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; height: 30px; padding: 0 14px; border-radius: 999px; color: var(--muted); cursor: pointer; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--canvas); color: var(--text); }

/* ---------- pills, marks ---------- */
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); white-space: nowrap; }
.pill.accent, .pill.news { background: var(--pill-accent-bg); color: var(--pill-accent-ink); }
.pill.positive { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.pill.warning { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }
.panel .pill, .topic .pill { background: var(--canvas); }
.panel .pill.accent, .topic .pill.accent, .topic .pill.news { background: var(--pill-accent-bg); }
.mark { --h: 330; display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 11px; font-weight: 600; font-size: 14px;
  background: hsl(var(--h) 70% 90%); color: hsl(var(--h) 50% 24%); }
.mark.lg { width: 52px; height: 52px; font-size: 18px; border-radius: 14px; }
.mark.dark-mark { background: var(--frame); color: #fff; width: 36px; height: 36px; border-radius: 9px; font-size: 13px; }
.mark.add { background: var(--soft-2); color: var(--text); }
.mark.add svg { width: 16px; height: 16px; }
.track { height: 6px; border-radius: 3px; background: var(--blue-soft); overflow: hidden; }
.track > i { display: block; height: 100%; background: var(--blue); border-radius: 3px; }

/* ---------- overview ---------- */
.ov-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 28px; margin-bottom: 32px; }
.ov-summary h2 { margin-bottom: 14px; min-height: 36px; display: flex; align-items: center; }
.summary-card { background: var(--blue-soft); border-radius: var(--r-card); padding: 20px 22px 16px; height: 196px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; }
.summary-figure { display: flex; flex-direction: column; }
.summary-figure b { font-size: 30px; line-height: 36px; font-weight: 700; letter-spacing: -0.02em; }
.summary-figure b span { font-size: 18px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.summary-figure > span { color: var(--muted); margin-top: 2px; }
.bars { display: flex; align-items: flex-end; justify-content: flex-end; gap: 12px; height: 100%; padding-top: 4px; }
.bar { display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; flex: 0 1 34px; }
.bar-track { width: 100%; max-width: 30px; background: #fff; border-radius: 8px; display: flex; align-items: flex-end; overflow: hidden; }
.bar-track i { display: block; width: 100%; background: var(--blue); border-radius: 8px; min-height: 0; }
.bar-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.bar:hover .bar-track i { background: #2c79cc; }

.brand-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.brand-card { --h: 330; background: hsl(var(--h) 70% 92%); border-radius: var(--r-card); padding: 18px; min-height: 196px; display: flex; flex-direction: column; transition: transform .2s var(--ease-out); }
.brand-card:hover { transform: translateY(-2px); }
.bc-top { display: flex; align-items: baseline; gap: 6px; }
.bc-top b { font-size: 24px; line-height: 30px; font-weight: 700; letter-spacing: -0.02em; }
.bc-top span { color: hsl(var(--h) 25% 32%); }
.bc-name { margin-top: 4px; font-weight: 500; color: hsl(var(--h) 30% 22%); }
.bc-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bc-foot .mark { background: #fff; color: var(--text); width: 40px; height: 40px; }
.bc-foot span { font-size: 12px; color: hsl(var(--h) 40% 26%); font-weight: 500; text-align: right; }

.ov-bottom { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr); gap: 28px; align-items: start; }
.brand-table { width: 100%; border-collapse: collapse; }
.brand-table th { text-align: left; font-weight: 400; font-size: 12px; color: var(--muted); padding: 0 8px 10px; }
.brand-table td { padding: 10px 8px; vertical-align: middle; }
.brand-table tbody tr { cursor: pointer; }
.brand-table tbody tr td:first-child { border-radius: 12px 0 0 12px; }
.brand-table tbody tr td:last-child { border-radius: 0 12px 12px 0; }
.brand-table tbody tr:hover td { background: var(--soft); }
.brand-cell { display: flex; align-items: center; gap: 12px; }
.brand-cell b { font-weight: 600; display: block; }
.brand-cell span { color: var(--muted); font-size: 12px; }
.th-num, .td-num { text-align: right; }
.td-num b { font-weight: 600; }

.next-card { position: relative; overflow: hidden; background: var(--frame); color: #fff; border-radius: 22px; padding: 28px; min-height: 240px; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; transition: transform .2s var(--ease-out); }
.next-card:hover { transform: translateY(-2px); }
.next-card h2 { font-size: 24px; line-height: 34px; font-weight: 700; max-width: 15em; position: relative; }
.next-card p { color: #c9cad1; max-width: 26em; position: relative; }
.next-card .btn { margin-top: auto; position: relative; }
.ring { display: inline-block; border: 1.5px solid #fff; border-radius: 999px; padding: 0 10px; line-height: 30px; transform: rotate(-3deg); }
.next-art { position: absolute; right: -18px; bottom: -14px; width: 170px; color: #4a4b52; stroke-width: 1.2; }

/* ---------- month workspace ---------- */
.month-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 28px; align-items: start; }
.brief-row { display: flex; gap: 12px; align-items: flex-start; }
.brief-row textarea { min-height: 46px; height: 46px; resize: none; overflow: hidden; }
.topics-list { display: grid; gap: 10px; padding: 16px 12px 12px; }
.topic { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; padding: 16px; background: var(--canvas); border-radius: 14px; border: 1.5px solid transparent; transition: border-color .15s; }
.topic.selected { border-color: var(--blue); }
.topic .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.topic .meta .pill { background: var(--soft); }
.topic p { color: var(--muted); margin-top: 4px; line-height: 20px; }
.topic .why { font-size: 13px; color: var(--faint); margin-top: 6px; }
.topic .why a { color: #164b85; text-decoration: underline; text-underline-offset: 2px; }
.topic .actions { display: flex; gap: 6px; align-items: flex-start; }
.pick { width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--control); background: var(--canvas); display: grid; place-items: center; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s; }
.pick svg { width: 16px; height: 16px; opacity: 0; }
.pick:hover { border-color: var(--blue); }
.pick[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }
.pick[aria-pressed="true"] svg { opacity: 1; }
.post-link { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 8px 10px; background: var(--soft); border-radius: 12px; margin-top: 4px; transition: background-color .15s; }
.post-link:hover { background: var(--blue-soft); }
.post-link .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.post-link img, .post-link .thumb-empty { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex: none; }
.post-link .pill { background: var(--canvas); }
.thumb-empty { background: var(--blue-soft); }

.feed-card { background: var(--blue-soft); }
.feed { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.feed a, .feed div { aspect-ratio: 1; position: relative; overflow: hidden; background: #fff; border-radius: 6px; }
.feed img { width: 100%; height: 100%; object-fit: cover; }
.feed .ph { position: absolute; inset: 0; padding: 8px; display: flex; align-items: flex-end; font-size: 11px; line-height: 13px; font-weight: 600; color: #164b85; background: #fff; }
.feed a .ph.on-photo { background: linear-gradient(transparent 40%, rgb(0 0 0 / .55)); color: #fff; } /* taste-skill-ignore: scrim under text on a photo */
.feed .empty-slot { border: 1.5px dashed #b9d3ee; background: transparent; }
.side-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 20px 20px; }
.side-stats div { background: #fff; border-radius: 12px; padding: 10px 12px; }
.side-stats b { display: block; font-size: 22px; line-height: 28px; font-weight: 700; }
.side-stats span { color: var(--muted); font-size: 12px; }
.step { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; }
.step:hover { background: var(--soft-2); }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }
.working { display: flex; align-items: center; gap: 12px; margin: 16px 12px 0; padding: 14px 16px; background: var(--blue-soft); color: #164b85; border-radius: 12px; }

/* ---------- post editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; }
.slides { display: grid; gap: 10px; }
.slide { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.slide .n { color: var(--faint); padding-top: 12px; font-size: 13px; text-align: right; }
.slide .inputs { display: grid; gap: 6px; }
.slide textarea { min-height: 44px; }
.rewrite { display: flex; gap: 8px; flex-wrap: wrap; }
.rewrite input { flex: 1; min-width: 200px; }
.rewrite .btn { height: 44px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 32px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--canvas); cursor: pointer; font-size: 13px; color: var(--muted); transition: background-color .15s, border-color .15s, color .15s; }
.chip:hover { border-color: var(--blue); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--frame); border-color: var(--frame); color: #fff; }

.preview { position: sticky; top: 16px; }
.ig { background: var(--canvas); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.ig-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; font-weight: 600; font-size: 13px; }
.ig-head .mark { width: 30px; height: 30px; font-size: 11px; border-radius: 50%; }
.ig-img { aspect-ratio: 4 / 5; position: relative; background: var(--soft); overflow: hidden; }
.ig-img img { width: 100%; height: 100%; object-fit: cover; }
.ig-img .overlay { position: absolute; inset: 0; display: flex; align-items: flex-end; padding: 22px; background: linear-gradient(transparent 35%, rgb(0 0 0 / .6)); } /* taste-skill-ignore: scrim under text on a photo */
.ig-img .overlay.plain { background: hsl(var(--h, 330) 70% 90%); align-items: center; }
.ig-img .overlay span { color: #fff; font-size: 24px; line-height: 27px; font-weight: 700; letter-spacing: -0.02em; }
.ig-img .overlay.plain span { color: hsl(var(--h, 330) 50% 20%); }
.ig-dots { display: flex; gap: 4px; justify-content: center; padding: 10px 0 0; }
.ig-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--control); }
.ig-dots i.on { background: var(--blue); }
.ig-nav { position: absolute; top: 50%; translate: 0 -50%; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgb(255 255 255 / .92); cursor: pointer; display: grid; place-items: center; }
.ig-nav svg { width: 16px; height: 16px; }
.ig-nav.prev { left: 8px; } .ig-nav.next { right: 8px; }
.ig-cap { padding: 10px 14px 14px; font-size: 13px; line-height: 19px; white-space: pre-wrap; max-height: 220px; overflow: auto; }
.ig-cap b { font-weight: 600; }
.ig-cap .tags { color: #164b85; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-grid button { padding: 0; border: 3px solid transparent; border-radius: 12px; overflow: hidden; cursor: pointer; aspect-ratio: 1; background: var(--soft-2); position: relative; transition: border-color .15s; }
.photo-grid button:hover { border-color: var(--blue-btn); }
.photo-grid button[aria-pressed="true"] { border-color: var(--blue); }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid .src { position: absolute; left: 6px; bottom: 6px; font-size: 11px; background: rgb(255 255 255 / .92); padding: 1px 8px; border-radius: 999px; color: var(--text); }
.credit { font-size: 12px; color: var(--muted); line-height: 17px; }
.credit a { text-decoration: underline; text-underline-offset: 2px; }
.skeleton { border-radius: 12px; background: var(--soft-2); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }

.notice { padding: 14px 18px; border-radius: 14px; background: var(--pill-warning-bg); color: var(--pill-warning-ink); }
.notice a { text-decoration: underline; font-weight: 500; }

/* ---------- settings ---------- */
.settings-row { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 32px; padding: 28px 0; border-bottom: 1px solid var(--line); }
.settings-row:first-of-type { padding-top: 4px; }
.settings-row:last-child { border-bottom: 0; }
.settings-row > div:first-child p { color: var(--muted); margin-top: 6px; line-height: 20px; }
.key-row { display: grid; grid-template-columns: 200px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.key-row:last-child { border-bottom: 0; }
.key-row .state { font-size: 13px; color: var(--muted); }
.key-row .state b { color: var(--positive); font-weight: 500; }
.key-row .edit { display: flex; gap: 8px; }
.key-row input { height: 36px; }
.key-row .getlink { color: #164b85; text-decoration: underline; text-underline-offset: 2px; }
.svc-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 8px; align-items: start; }

/* ---------- login ---------- */
.login { min-height: 100svh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 380px; display: grid; gap: 16px; background: var(--canvas); border-radius: var(--r-canvas); padding: 32px; }
.login .logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; margin-bottom: 8px; }
.login .logo .rail-logo { width: 38px; height: 38px; margin: 0; font-size: 20px; border-radius: 11px; }
.login .err { color: var(--negative); min-height: 20px; }

/* ---------- sheet (phone brands menu) ---------- */
.sheet { position: fixed; inset: 0; background: rgb(18 19 22 / .4); z-index: 40; display: flex; align-items: flex-end; }
.sheet-panel { width: 100%; background: var(--canvas); border-radius: 24px 24px 0 0; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); display: grid; gap: 4px; max-height: 80svh; overflow: auto; animation: up .25s var(--ease-out); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 8px; }
.sheet-brand { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 14px; min-height: 56px; }
.sheet-brand[aria-current="page"] { background: var(--soft); }
.sheet-brand > span:not(.mark) { flex: 1; display: grid; }
.sheet-brand small { color: var(--muted); font-size: 12px; }
.sheet-brand > svg { width: 16px; height: 16px; color: var(--faint); }

/* ---------- toast, loading ---------- */
#toast { position: fixed; left: 50%; bottom: 28px; translate: -50% 16px; background: var(--frame); color: #fff; padding: 12px 18px; border-radius: 14px; opacity: 0; pointer-events: none; transition: opacity .2s var(--ease-out), translate .2s var(--ease-out); box-shadow: 0 8px 24px rgb(0 0 0 / .18); max-width: calc(100vw - 32px); z-index: 50; }
#toast.on { opacity: 1; translate: -50% 0; }
#toast.err { background: var(--negative); }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { rotate: 360deg; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation-duration: 0s !important; } .spin { animation: spin 1.5s linear infinite !important; } }

/* ---------- tablet ---------- */
@media (max-width: 1180px) {
  .month-grid, .editor { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; max-width: 420px; }
  .ov-top, .ov-bottom { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- phone: no frame, dark bottom bar ---------- */
@media (max-width: 760px) {
  :root { --pad: 16px; --gap: 14px; }
  body { background: var(--canvas); }
  .only-phone { display: grid !important; }
  .rail-item.only-phone { display: flex !important; }
  .only-desktop, .only-desktop-inline { display: none !important; }
  .app { display: block; margin: 0; padding: 0; border-radius: 0; background: var(--canvas); min-height: 100svh; }
  .main { border-radius: 0; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .rail { position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; z-index: 30; flex-direction: row; justify-content: space-around; gap: 0;
    background: var(--frame); border-radius: 22px 22px 0 0; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
  .rail-logo, .rail-brands, .rail-gap, .rail-group { display: none; }
  .rail-item { width: auto; flex: 1; height: 56px; padding: 0; display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center; background: transparent !important; }
  .rail-item[aria-current="page"]::before { left: 30%; right: 30%; top: -8px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .rail-label { font-size: 11px; line-height: 13px; font-weight: 400; }
  .topbar { position: sticky; top: 0; z-index: 20; background: var(--canvas); padding: 10px var(--pad); min-height: 56px; }
  .crumbs .hide-sm { display: none; }
  .month-switch .label { min-width: 0; padding: 0 4px; font-size: 13px; }
  .canvas { padding: 8px var(--pad) var(--pad); }
  h1 { font-size: 26px; line-height: 32px; }
  .title-row { margin-bottom: 20px; }
  .title-row .grow { min-width: 0; flex-basis: 100%; }
  .title-row > .btn { flex: 1; }
  .two, .svc-row, .settings-row { grid-template-columns: minmax(0, 1fr); }
  .settings-row { gap: 16px; padding: 22px 0; }
  .key-row { grid-template-columns: 1fr auto; }
  .key-row .state { grid-column: 1 / -1; grid-row: 2; }
  .key-row .edit { grid-column: 1 / -1; flex-wrap: wrap; }
  .key-row .edit input { flex: 1 1 100%; }

  .summary-card { height: 168px; padding: 16px; gap: 12px; }
  .summary-figure b { font-size: 26px; line-height: 32px; }
  .brand-cards { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: var(--pad); margin: 0 calc(var(--pad) * -1); padding: 0 var(--pad) 4px; scrollbar-width: none; }
  .brand-card { flex: 0 0 150px; min-height: 170px; scroll-snap-align: start; }
  .ov-top { gap: 24px; margin-bottom: 24px; }
  .next-card { min-height: 0; padding: 22px; }
  .next-card h2 { font-size: 21px; line-height: 30px; }
  .brand-table td { padding: 10px 4px; }
  .brand-table th { padding: 0 4px 8px; }
  .brand-table .hide-sm { display: none; }

  .brief-row { flex-direction: column; align-items: stretch; }
  .topics-list { padding: 12px 8px 8px; }
  .topic { grid-template-columns: minmax(0, 1fr) auto; padding: 14px; }
  .topic .actions { flex-direction: column-reverse; }
  .feed { gap: 3px; }
  .preview { max-width: none; }
  #toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
