:root {
  color-scheme: light;
  --bg: #fff4f8;
  --surface: #ffffff;
  --text: #2d1822;
  --muted: #5c3144;
  --pink: #9d1454;
  --pink-soft: #ffe4ef;
  --border: #f0c3d4;
  --ok: #06643b;
  --danger: #9f1239;
  --shadow: 0 10px 30px rgba(157, 20, 84, .08);
  --header: 64px;
  --tab: 62px;
  --panel: 240px;
  --gap: 16px;
  --font: "Outfit", "Segoe UI", sans-serif;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1016;
  --surface: #2a1822;
  --text: #fff1f6;
  --muted: #f6d0de;
  --pink: #ffb3d0;
  --pink-soft: #4a2434;
  --border: #6e4054;
  --ok: #86efac;
  --danger: #fecdd3;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; max-width: 100%; overflow-x: clip; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100dvh;
}
img { max-width: 100%; height: auto; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }
.skip {
  position: absolute; left: 8px; top: -40px; background: var(--surface); padding: 8px 12px; z-index: 5;
}
.skip:focus { top: 8px; }
.app { display: flex; min-height: 100dvh; min-width: 0; }
.panel {
  width: var(--panel); flex: 0 0 var(--panel); background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100dvh; min-width: 0;
}
.panel-brand, .panel-nav a, .topbar, .tabbar, .actions, .toolbar, .filters, .item-row-bottom, .inline-form {
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.panel-brand { padding: 16px; }
.panel-brand img { width: 42px; height: 42px; object-fit: contain; border-radius: 8px; }
.brand-copy { display: flex; flex-direction: column; min-width: 0; }
.brand-copy strong { font-size: 1rem; }
.brand-copy small, .top-title span, .hint, .panel-foot, .lede { color: var(--muted); }
.panel-nav { display: flex; flex-direction: column; gap: 4px; padding: 0 10px; }
.panel-nav a, .tabbar a, .tabbar button {
  min-height: 44px; border-radius: 12px; text-decoration: none; padding: 8px 12px;
  color: var(--text); background: transparent; border: 0;
}
.panel-nav a.is-active, .tabbar a.is-active { background: var(--pink-soft); font-weight: 700; }
.panel-foot { margin-top: auto; padding: 16px; font-size: .85rem; }
.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
  padding: 8px 12px; flex-wrap: wrap; justify-content: space-between;
}
.top-title { display: flex; flex-direction: column; min-width: 0; }
.top-title strong, .top-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28vw; }
.content, .plain {
  padding: var(--gap); min-width: 0;
  display: flex; flex-direction: column; gap: var(--gap);
}
.plain { max-width: 760px; margin: 0 auto; }
.plain-brand { display: flex; justify-content: center; padding: 12px 0 4px; }
.tabbar {
  display: none; position: sticky; bottom: 0; background: var(--surface);
  border-top: 1px solid var(--border); justify-content: space-around;
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}
.tabbar a, .tabbar button {
  flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center;
  text-align: center; min-width: 0;
}
.tabbar .icon-btn { width: auto; border: 0; background: transparent; flex: 1 1 0; }
.card, .data-card, .metrics article {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); padding: 16px; min-width: 0;
}
h1 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 6px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
.page-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin: 0; }
.page-head p, .lede { margin: 0; }
label, .check { display: flex; flex-direction: column; gap: 6px; font-weight: 650; margin: 0 0 12px; min-width: 0; }
.check { flex-direction: row; align-items: center; font-weight: 600; }
input, select, textarea {
  width: 100%; min-height: 44px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); padding: 8px 12px;
}
textarea { min-height: 88px; resize: vertical; }
.grid-2, .grid-3 { display: grid; gap: 12px; grid-template-columns: 1fr; }
.btn, button.btn, a.btn {
  min-height: 44px; border-radius: 12px; border: 1px solid transparent; padding: 8px 14px;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-weight: 700; background: var(--surface); flex: 0 0 auto;
  line-height: 1.2; text-align: center;
}
button.btn-primary,
a.btn-primary { background: #9d1454; color: #fff; }
[data-theme="dark"] button.btn-primary,
[data-theme="dark"] a.btn-primary { background: #ffb3d0; color: #2a1020; }
button.btn-ghost,
a.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
button.btn-danger,
a.btn-danger { background: #9f1239; color: #fff; }
[data-theme="dark"] button.btn-danger,
[data-theme="dark"] a.btn-danger { background: #fecdd3; color: #4c0519; }
button.btn-wa,
a.btn-wa { background: #067647; color: #fff; }
[data-theme="dark"] button.btn-wa,
[data-theme="dark"] a.btn-wa { background: #86efac; color: #052e16; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); line-height: 0; flex: 0 0 44px;
}
.icon-btn svg { display: block; }
.theme-form fieldset, .inline-radio, .choice {
  border: 1px solid var(--border); border-radius: 12px; margin: 0; padding: 6px; min-width: 0;
}
.theme-form { margin-left: auto; }
.theme-form label, .inline-radio label, .choice-card {
  flex-direction: row; align-items: center; margin: 0; font-weight: 650; min-height: 44px; padding: 0 8px;
}
.theme-form fieldset, .inline-radio { display: flex; flex-wrap: wrap; gap: 4px; }
.theme-form legend, .inline-radio legend, .choice legend { padding: 0 6px; }
.kawaii-theme,
.theme-form fieldset.kawaii-theme {
  position: relative; display: flex; flex-wrap: wrap; gap: 4px; width: fit-content;
  margin: 0; padding: 4px; border: 0; border-radius: 999px;
  background: #ffe4f0; box-shadow: inset 0 0 0 2px #f7c3d6;
}
.kawaii-theme legend {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
}
.card .kawaii-theme { margin-bottom: 12px; }
.card .kawaii-theme legend {
  position: static; width: auto; height: auto; overflow: visible; clip: auto;
  flex-basis: 100%; padding: 0 8px 4px; font-weight: 700; color: var(--text);
}
.kawaii-theme label {
  position: relative; display: inline-flex; flex-direction: row; align-items: center; gap: 6px;
  min-height: 40px; margin: 0; padding: 4px 12px 4px 4px; border-radius: 999px;
  cursor: pointer; font-weight: 700; color: #8a4562;
}
.kawaii-theme input {
  position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; margin: 0;
}
.kawaii-pip {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 30px;
  background: #fff center / 22px 22px no-repeat;
  box-shadow: 0 2px 0 #f3b6cc;
}
.kawaii-sun {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='16' r='7' fill='%23ffd56a'/%3E%3Ccircle cx='13.4' cy='15' r='1.1' fill='%235a3a1a'/%3E%3Ccircle cx='18.6' cy='15' r='1.1' fill='%235a3a1a'/%3E%3Cpath d='M13 18.4c1 1.3 5 1.3 6 0' fill='none' stroke='%23e07a9a' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E");
}
.kawaii-moon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath fill='%23c9b6ff' d='M18.2 8.2a7.2 7.2 0 1 0 5.4 11.6 6.4 6.4 0 1 1-5.4-11.6z'/%3E%3Ccircle cx='14.2' cy='14.6' r='1' fill='%234a3568'/%3E%3Ccircle cx='17.6' cy='13.8' r='1' fill='%234a3568'/%3E%3Cpath d='M14 17.6c.7.8 2.8.8 3.6 0' fill='none' stroke='%23f3a0c0' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
}
.kawaii-theme label:has(input:checked) {
  background: #fff; color: #9d1454; box-shadow: 0 3px 0 #f3b6cc;
}
.kawaii-theme label:has(input:checked) .kawaii-pip { transform: scale(1.06); }
.kawaii-theme label:has(input:focus-visible) { outline: 3px solid #9d1454; outline-offset: 2px; }
[data-theme="dark"] .kawaii-theme,
[data-theme="dark"] .theme-form fieldset.kawaii-theme { background: #3a2230; box-shadow: inset 0 0 0 2px #6e4054; }
[data-theme="dark"] .kawaii-theme label { color: #f6d0de; }
[data-theme="dark"] .kawaii-theme label:has(input:checked) {
  background: #ffd6e7; color: #6a2348; box-shadow: 0 3px 0 #8a4d68;
}
[data-theme="dark"] .kawaii-pip { box-shadow: 0 2px 0 #8a4d68; }
.actions, .toolbar, .command-bar { flex-wrap: wrap; align-items: center; margin: 0; gap: 8px; }
.command-bar {
  display: flex; position: sticky; top: 60px; z-index: 15;
  background: var(--bg); padding: 0;
}
.panel-nav .ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; height: 1.5rem; flex: 0 0 1.5rem; line-height: 1;
}
.flash { border-radius: 12px; padding: 12px 14px; margin: 0; }
.flash-success { background: #ecfdf3; color: #064e3b; }
.flash-error { background: #fff1f2; color: #881337; }
[data-theme="dark"] .flash-success { background: #064e3b; color: #ecfdf3; }
[data-theme="dark"] .flash-error { background: #4c0519; color: #ffe4e6; }
.month-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: var(--gap); margin: 0; }
.month-seg {
  display: flex; flex-direction: column; gap: 2px; min-height: 76px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  color: var(--text); text-decoration: none;
}
.month-seg span, .month-seg small { color: var(--muted); font-size: 0.8rem; }
.month-seg strong { font-size: 0.95rem; overflow-wrap: anywhere; }
.month-seg.is-active { border-color: #9d1454; background: var(--pink-soft); }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--gap); margin: 0; }
.metrics p { font-size: 1.25rem; font-weight: 800; margin: 4px 0; overflow-wrap: anywhere; }
.filters { flex-wrap: wrap; align-items: end; }
.filters label { flex: 1 1 160px; margin: 0; }
.table-scroll { overflow: auto; max-width: 100%; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.table-scroll table { border-collapse: collapse; width: max-content; min-width: 100%; }
.table-scroll th, .table-scroll td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; white-space: nowrap; color: var(--text); }
.table-scroll th { position: sticky; top: 0; background: var(--pink-soft); }
.table-scroll td.row-actions { width: 1%; white-space: nowrap; }
.table-scroll .row-actions { display: flex; gap: 6px; align-items: center; }
.table-scroll .row-actions .btn {
  min-height: 28px; height: 28px; padding: 0 10px; font-size: 0.78rem; font-weight: 650;
  border-radius: 8px; line-height: 1;
}
.card-list, .stack, .split { display: grid; gap: var(--gap); margin: 0; }
.card-list.only-narrow { display: none; }
.data-card header { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.data-card p { overflow-wrap: anywhere; }
.row-actions { display: flex; gap: 6px; }
.creator { display: grid; gap: var(--gap); min-width: 0; }
.creator-form, .creator-preview { min-width: 0; }
.item-row { border: 1px solid var(--border); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.item-row-bottom { flex-wrap: wrap; align-items: end; }
.item-row-bottom label { flex: 1 1 120px; margin: 0; }
.btn-remove-item { align-self: end; }
.summary { display: grid; gap: 6px; padding: 12px; border-radius: 12px; background: var(--pink-soft); }
.summary div, .summary-total { display: flex; justify-content: space-between; gap: 12px; }
.summary-total { font-size: 1.15rem; }
.preview-fit { width: 100%; overflow: hidden; display: flex; justify-content: center; }
.preview-scale { width: 680px; transform-origin: top center; }
.choice { display: grid; gap: 8px; margin-bottom: 12px; }
.choice-card { border: 1px solid var(--border); border-radius: 12px; padding: 8px; }
.choice-card span { display: flex; flex-direction: column; }
.code { overflow: auto; max-height: 320px; padding: 12px; background: var(--bg); border-radius: 12px; white-space: pre; }
dialog { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); max-width: min(440px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(20, 8, 14, .45); }
.setup-card, .auth-card { max-width: 720px; margin: 0 auto; }
.account-hero, .account-grid { width: 100%; max-width: 880px; }
.account-hero { display: flex; align-items: center; gap: 16px; }
.account-hero h2 { margin: 0; }
.account-hero .hint { margin: 2px 0 0; }
.account-avatar {
  width: 64px; height: 64px; border-radius: 50%; flex: 0 0 64px;
  display: grid; place-items: center;
  background: #ffe4f0; color: #9d1454; font-size: 1.5rem; font-weight: 800;
}
[data-theme="dark"] .account-avatar { background: #4a2434; color: #ffd6e7; }
.account-grid { display: grid; grid-template-columns: 1fr; gap: var(--gap); }
.account-save { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
@media (min-width: 800px) {
  .account-grid { grid-template-columns: 1fr 1fr; align-items: start; }
  .account-save { grid-column: 1 / -1; }
}
.toasts { position: fixed; right: 12px; bottom: 76px; display: grid; gap: 8px; z-index: 50; max-width: min(360px, calc(100vw - 24px)); }
.toast { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); }
.backdrop { position: fixed; inset: 0; background: rgba(20,8,14,.45); z-index: 30; }
#openPanel { display: none; }
@media (min-width: 800px) and (max-width: 1099px) {
  .creator .grid-3, .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1100px) {
  .creator { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: start; }
  .creator-form, .creator-preview { max-height: calc(100dvh - 110px); overflow: auto; }
  .creator .grid-3 { grid-template-columns: 1fr; }
}
@media (min-width: 1500px) {
  .creator .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 1199px) {
  .panel {
    position: fixed; z-index: 40; transform: translateX(-105%); transition: transform .2s ease;
    width: min(280px, 88vw); height: 100dvh; flex-basis: auto;
  }
  .panel.is-open { transform: none; }
  #openPanel { display: inline-flex; }
}
@media (max-width: 767px) {
  .tabbar { display: flex; }
  .content { padding-bottom: calc(var(--tab) + var(--gap)); }
  .table-scroll.only-wide { display: none; }
  .card-list.only-narrow { display: grid; }
  .top-title strong, .top-title span { max-width: 34vw; }
  .command-bar { top: 56px; }
}
@media (max-width: 420px) {
  .theme-form legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
@media print {
  .panel, .topbar, .tabbar, .creator-form, .toolbar, .command-bar, .backdrop, .toasts, .skip { display: none !important; }
  .app, .app-main, .content, .creator, .creator-preview, .preview-fit, .preview-scale {
    display: block !important; height: auto !important; max-height: none !important; overflow: visible !important; transform: none !important; width: auto !important;
  }
  body { background: #fff !important; }
}
