@import url('https://fonts.googleapis.com/css2?family=Mali:wght@500;600;700&display=swap');

/* Cozy Studio: the management page (core/settings.js) and the Gacha control panel. */
:root {
  --bg: #f4ebdd; --card: #fffaf2; --ink: #4e3220; --muted: #8a6d55; --line: #ead9c3;
  --accent: #e7805f; --accent-soft: #fde6da; --accent-ink: #fff;
  --ok: #5fa964; --ok-soft: #e3f3e0; --warn: #d9a440; --warn-soft: #fbefcf; --bad: #cf5f5f;
  --shadow: 0 1px 0 #fff inset, 0 6px 18px rgba(120, 80, 40, .08);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 'Mali', 'Leelawadee UI', system-ui, sans-serif;
  background-image: radial-gradient(circle at 12% 0%, #fbf3e6 0, transparent 45%), radial-gradient(circle at 100% 30%, #f8e6d6 0, transparent 40%); background-attachment: fixed; }

header { display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
header h1 { font-size: 18px; margin: 0; line-height: 1.2; flex: 1; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand small { color: var(--muted); font-size: 12px; letter-spacing: .04em; }
.logo { width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); display: grid; place-items: center; font-size: 22px; flex: none; }
.lang { display: flex; background: var(--bg); border-radius: 999px; padding: 3px; flex: none; }
.lang button { border: 0; background: none; color: var(--muted); border-radius: 999px; padding: 2px 12px; font: inherit; cursor: pointer; }
.lang button.on { background: var(--ink); color: var(--card); }

/* layout: nav | content | preview */
.shell { display: grid; grid-template-columns: 168px minmax(0, 560px) minmax(260px, 1fr); gap: 18px; padding: 18px; align-items: start; max-width: 1500px; margin: 0 auto; }
nav { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 4px; }
nav button { display: flex; align-items: center; gap: 10px; border: 0; background: none; color: var(--muted); font: 600 15px inherit; font-family: inherit; padding: 9px 12px; border-radius: 12px; cursor: pointer; text-align: left; }
nav button:hover { background: rgba(255, 250, 242, .7); color: var(--ink); }
nav button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
nav .ic { width: 26px; text-align: center; font-size: 17px; }
.content { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pane { display: flex; flex-direction: column; gap: 12px; }
.preview { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
body.wide-pane .shell { grid-template-columns: 168px minmax(0, 1fr); }
body.wide-pane .preview { display: none; }

@media (max-width: 1080px) {
  .shell { grid-template-columns: 168px minmax(0, 1fr); }
  .preview { grid-column: 2; position: static; }
}
@media (max-width: 720px) {   /* OBS dock width */
  .shell, body.wide-pane .shell { grid-template-columns: minmax(0, 1fr); padding: 10px; gap: 10px; }
  nav { position: sticky; top: 61px; z-index: 4; flex-direction: row; overflow-x: auto; background: var(--bg); padding: 4px 0; margin: -4px 0; }
  nav button { flex-direction: column; gap: 0; padding: 5px 10px; font-size: 12px; flex: 1 0 auto; align-items: center; }
  .preview { grid-column: 1; }
  header { padding: 8px 10px; } .logo { width: 34px; height: 34px; font-size: 18px; }
}

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; box-shadow: var(--shadow); }
.card h2 { font-size: 16px; margin: 0 0 8px; display: flex; align-items: center; gap: 10px; }
.lead { color: var(--muted); margin: 0 0 8px; font-size: 14px; }
.hint { color: var(--muted); font-size: 12.5px; }
.card ol, .card ul { margin: 4px 0 10px; padding-left: 22px; }
.card li { margin: 3px 0; }
.card li b, .lead b { color: var(--ink); background: var(--accent-soft); border-radius: 6px; padding: 0 6px; }
details summary { cursor: pointer; font-weight: 600; color: var(--muted); }
details[open] summary { margin-bottom: 6px; }
.hero { background: linear-gradient(135deg, #fff7ea, #fdebdc); }
.hero h2 { font-size: 19px; }
.q { font-weight: 700; margin: 12px 0 6px; }

/* numbered steps: the counter skips hidden steps by itself */
.steps { counter-reset: step; display: flex; flex-direction: column; gap: 12px; }
.step { counter-increment: step; }
.step .num { background: var(--accent); color: var(--accent-ink); width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 14px; flex: none; }
.step .num::before { content: counter(step); }
body[data-app="obs"] .app-studio, body[data-app="studio"] .app-obs { display: none !important; }
.light { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.fix { color: var(--bad); font-size: 13px; }
.fix:empty { display: none; }
.note { background: var(--warn-soft); border-radius: 12px; padding: 10px 12px; margin-top: 10px; font-size: 13.5px; }
.note ul { margin-bottom: 0; }
.tests, .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }

/* link mode bar */
.mode { display: flex; align-items: center; gap: 10px; background: var(--warn-soft); border-radius: 14px; padding: 8px 12px; font-size: 13.5px; }
.mode #modeText { flex: 1; }
.mode .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); flex: none; }
.mode.on { background: var(--ok-soft); }
.mode.on .dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(95, 169, 100, .2); }
.mode.on .btn { display: none; }
.warn { background: #fbe1e1; border-radius: 14px; padding: 8px 12px; font-size: 13.5px; }

/* fields */
.field { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 8px 0; }
.field + .field { border-top: 1px dashed var(--line); }
.field label { font-weight: 600; }
.field .hint { grid-column: 1 / -1; }
.field input[type=range] { width: 150px; accent-color: var(--accent); }
.field input[type=text], .field input[type=password], .field input[type=number], input[type=text], select { width: 160px; padding: 6px 10px; border: 1.5px solid var(--line); border-radius: 10px; font: inherit; color: var(--ink); background: #fff; }
.field input:focus, .url input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field .val { min-width: 4ch; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.field .range { display: flex; gap: 8px; align-items: center; }

.switch { position: relative; width: 44px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }

.chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 12px 3px 6px; cursor: pointer; font-weight: 500; user-select: none; }
.chips label:not(:has(img)) { padding-left: 12px; }
.chips label img { height: 30px; }
.chips input { display: none; }
.chips label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.chips.big label { padding: 7px 16px; font-weight: 600; border-radius: 14px; }
.chips.big label:has(input:checked)::before { content: '✓'; color: var(--accent); font-weight: 700; }

.badge { font-size: 12.5px; padding: 2px 10px; border-radius: 999px; background: var(--line); color: var(--ink); }
.badge.ok { background: var(--ok); color: #fff; } .badge.bad { background: var(--bad); color: #fff; } .badge.wait { background: var(--warn); color: #fff; }

.btn { border: 0; border-radius: 12px; padding: 8px 16px; font: 700 15px 'Mali', sans-serif; cursor: pointer; background: var(--accent); color: var(--accent-ink); white-space: nowrap; }
.btn:hover { filter: brightness(1.05); } .btn:active { transform: translateY(1px); }
.btn.small { padding: 3px 12px; font-size: 13px; }
.btn.ghost, button.small { background: none; color: var(--ink); border: 1.5px solid var(--line); border-radius: 10px; padding: 3px 12px; font: 600 13px 'Mali', sans-serif; cursor: pointer; }
.btn.soft { background: var(--accent-soft); color: var(--ink); }
.btn.danger { color: var(--bad); border-color: transparent; align-self: flex-start; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.url { display: flex; gap: 8px; margin: 6px 0; }
.url input { flex: 1; min-width: 0; width: auto; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 12px; font: 12.5px monospace; color: var(--ink); background: #fff; }

/* preview */
.preview .bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.preview .frame { background: repeating-conic-gradient(#e3d6c4 0 25%, #efe5d6 0 50%) 0 0 / 20px 20px; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; display: grid; place-items: center; padding: 12px; }
.preview .pvwrap { position: relative; overflow: hidden; border-radius: 10px; }
.preview iframe { position: absolute; left: 0; top: 0; border: 0; transform-origin: 0 0; background: transparent; }
.preview .bg-dark .pvwrap { background: #3b2f45; }
iframe.control { width: 100%; height: calc(100vh - 190px); min-height: 420px; border: 0; border-radius: 18px; background: var(--card); }

/* the control panel inside the Live tab drops its own header */
body.embed { background: none; }
body.embed header h1, body.embed header .lang { display: none; }
body.embed header { position: static; background: none; border: 0; padding: 4px 10px; justify-content: flex-end; }

/* per-platform event table */
.plat { margin: 4px 0 10px; }
.chips.plat label.tiktok:has(input:checked) { border-color: #25b8be; background: #e2f8f9; }
.chips.plat label.twitch:has(input:checked) { border-color: #9b6bff; background: #efe8ff; }
.chips.plat label.youtube:has(input:checked) { border-color: #ff5a5a; background: #ffe6e6; }
.chips.plat label.kick:has(input:checked) { border-color: #3fbf12; background: #e6f9de; }
.evtable { display: flex; flex-direction: column; margin-bottom: 10px; }
.evrow { display: grid; grid-template-columns: minmax(110px, 1fr) minmax(0, 1.5fr); gap: 6px 10px; align-items: center; padding: 9px 0; }
.evrow + .evrow { border-top: 1px dashed var(--line); }
.evrow.off .evname { color: var(--muted); }
.evname { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.evrow select { width: 100%; }
.evrow .min { grid-column: 2; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.evrow .min input { width: 84px; padding: 4px 8px; border: 1.5px solid var(--line); border-radius: 10px; font: inherit; color: var(--ink); background: #fff; }
.evrow .min input:disabled { opacity: .45; }
.tag { font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 0 8px; }

/* gift list (tug of war) */
.field.wide { grid-template-columns: 1fr; }
.gifts { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.gift { display: grid; grid-template-columns: minmax(0, 1fr) auto 76px auto; gap: 6px; align-items: center; border-radius: 12px; padding: 5px 6px; }
.gift.plus { background: var(--ok-soft); } .gift.minus { background: #fbe1e1; }
.gift input, .gift select { width: 100%; min-width: 0; padding: 5px 8px; border: 1.5px solid var(--line); border-radius: 10px; font: inherit; color: var(--ink); background: #fff; }
.gifts > .btn { align-self: flex-start; }

/* backup card */
#backup textarea { width: 100%; min-height: 64px; margin: 6px 0; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 12px; font: 12px/1.4 Consolas, monospace; color: var(--ink); background: #fff; resize: vertical; }
#bkMsg { background: var(--warn-soft); border-radius: 12px; padding: 8px 12px; margin-top: 8px; }
