/* 바오마당 — 포털 스타일. 앱 아이콘의 초록(#1c8554)을 기준색으로 쓴다. */
/* theme:v2 — 색은 가족 앱 style.css 와 같다 */
:root {
  --ground: #f3f1eb; --panel: #ffffff; --panel-2: #f8f6f1; --panel2: #f8f6f1; --warn: #b45309; --paper: #fbf6ea; --line: #e2ddd2; --line-soft: #ece8df;
  --ink: #1c211d; --muted: #5c645d; --faint: #8b918a;
  --accent: #2d6a4f; --accent-strong: #235740; --accent-ink: #ffffff; --accent-soft: #e2eee6;
  --warm: #c8663a; --warm-soft: #fbeadf;
  --sun: #c43d2b; --sat: #2e61ad; --danger: #b42318; --warn-soft: #fcefd9;
  --on-cat: #ffffff;
  --shadow: 0 1px 2px rgba(44, 36, 20, .05), 0 6px 20px rgba(44, 36, 20, .06);
  --shadow-lg: 0 12px 40px rgba(44, 36, 20, .16);
  --radius: 16px;
  --tip-bg: #1f2420; --tip-ink: #f4f3ee;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ground: #121513; --panel: #1a1e1b; --panel-2: #212622; --panel2: #212622; --warn: #f0a44b; --paper: #1f1d18; --line: #2e3430; --line-soft: #252a26;
  --ink: #e8ebe7; --muted: #a3aba4; --faint: #798179;
  --accent: #7cc39c; --accent-strong: #97d3b2; --accent-ink: #0d2016; --accent-soft: #1d3127;
  --warm: #ee9a6c; --warm-soft: #3a2619;
  --sun: #f08a78; --sat: #8db2f0; --danger: #ff7b6e; --warn-soft: #3a2c16;
  --on-cat: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-lg: 0 16px 44px rgba(0, 0, 0, .55);
  --tip-bg: #f1f0ea; --tip-ink: #151815;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #121513; --panel: #1a1e1b; --panel-2: #212622; --panel2: #212622; --warn: #f0a44b; --paper: #1f1d18; --line: #2e3430; --line-soft: #252a26;
    --ink: #e8ebe7; --muted: #a3aba4; --faint: #798179;
    --accent: #7cc39c; --accent-strong: #97d3b2; --accent-ink: #0d2016; --accent-soft: #1d3127;
    --warm: #ee9a6c; --warm-soft: #3a2619;
    --sun: #f08a78; --sat: #8db2f0; --danger: #ff7b6e; --warn-soft: #3a2c16;
    --on-cat: #ffffff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .3);
    --shadow-lg: 0 16px 44px rgba(0, 0, 0, .55);
    --tip-bg: #f1f0ea; --tip-ink: #151815;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--ink); font: 15px/1.6 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif; }
a { color: var(--accent); }
h1, h2 { line-height: 1.3; margin: 0 0 .4em; text-wrap: balance; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.1rem; }
.muted { color: var(--muted); } .small { font-size: .88rem; }
code { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; font-size: .9em; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* 머리글 */
.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; padding: 10px max(16px, env(safe-area-inset-left)); background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; }
.brand img { border-radius: 8px; }
.nav { display: flex; gap: 4px; margin-left: 6px; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; }
.nav a.on, .nav a:hover { background: var(--accent-soft); color: var(--accent); }
.count { display: inline-block; min-width: 20px; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .75rem; text-align: center; }
.me { margin-left: auto; position: relative; }
.me summary { list-style: none; cursor: pointer; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-weight: 600; }
.me summary::-webkit-details-marker { display: none; }
.me .menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; display: flex; flex-direction: column; gap: 6px; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.me .menu a, .me .menu button { text-align: left; padding: 6px 8px; border-radius: 8px; background: none; border: 0; color: var(--ink); text-decoration: none; font: inherit; cursor: pointer; }
.me .menu a:hover, .me .menu button:hover { background: var(--panel2); }

/* 본문 */
.page { max-width: 1040px; margin: 0 auto; padding: 22px 16px 60px; display: flex; flex-direction: column; gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; box-shadow: var(--shadow); }
.card.narrow { max-width: 420px; width: 100%; margin: 28px auto 0; }
.card.attention { border-color: var(--warn); }
.auth-logo { display: block; border-radius: 16px; margin-bottom: 12px; }
.hello h1 { font-size: 1.6rem; }
.notice { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--ink); }
.error { color: var(--danger); font-weight: 600; }

/* 타일 */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; color: var(--ink); text-decoration: none; box-shadow: var(--shadow); transition: transform .12s, border-color .12s; }
.tile:hover { border-color: var(--tile, var(--accent)); transform: translateY(-2px); }
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tile-top { display: flex; align-items: flex-start; justify-content: space-between; }
.tile-icon { border-radius: 13px; }
.tile-icon.letter { width: 48px; height: 48px; display: grid; place-items: center; background: var(--tile, var(--accent)); color: #fff; font-weight: 800; font-size: 1.3rem; }
.tile-icon.letter.small { width: 28px; height: 28px; font-size: .9rem; border-radius: 8px; }
.tile-name { font-weight: 700; font-size: 1.05rem; margin-top: 6px; }
.tile-desc { color: var(--muted); font-size: .9rem; min-height: 2.9em; }
.tile-status { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.dot.warn { background: var(--warn); } .dot.off { background: var(--line); }
.badge { min-width: 24px; padding: 1px 8px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .8rem; font-weight: 700; text-align: center; }
.install-tip { text-align: center; }
.empty { text-align: center; }

/* 폼 */
.form { display: flex; flex-direction: column; gap: 12px; }
.form.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px 16px; align-items: end; }
.form.row { flex-direction: row; flex-wrap: wrap; align-items: end; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .92rem; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
input, select { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; min-width: 0; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
input[type=color] { padding: 2px; height: 42px; }
input.short { width: 90px; }
input:focus-visible, select:focus-visible, button:focus-visible, .button:focus-visible { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
button, .button { font: inherit; font-weight: 600; cursor: pointer; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); text-decoration: none; display: inline-block; text-align: center; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.small, .button.small { padding: 5px 10px; font-size: .85rem; }
button.danger, .button.danger { color: var(--danger); }
button.linkish { background: none; border: 0; color: var(--accent); padding: 0; text-decoration: underline; }
fieldset.who { grid-column: 1 / -1; border: 1px dashed var(--line); border-radius: 12px; display: flex; flex-wrap: wrap; gap: 6px 18px; }

/* 표 */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 560px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }
td.actions { display: flex; flex-wrap: wrap; gap: 6px; }
td.actions form { margin: 0; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; border: 1px solid var(--line); color: var(--muted); }
.chip.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip.off { color: var(--danger); }
details.sub, details.app-row { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--panel2); }
details.sub summary, details.app-row summary { cursor: pointer; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
details.app-row summary img { border-radius: 7px; }
details[open] > summary { margin-bottom: 12px; }
.inline-right { display: flex; justify-content: flex-end; margin-top: 8px; }

@media (max-width: 640px) {
  .bar { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; margin: 0; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { padding: 12px; border-radius: 16px; }
  .tile-desc { display: none; }
}
@media (prefers-reduced-motion: reduce) { .tile { transition: none; } }

/* ---- 머리글 오른쪽: 검색 · 알림 · 화면(테마·글씨) 아이콘 */
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.top-btn { position: relative; width: 42px; height: 42px; min-height: 0; padding: 0; display: inline-grid; place-items: center; border-radius: 12px; border: 0; background: transparent; color: var(--muted); text-decoration: none; cursor: pointer; list-style: none; -webkit-tap-highlight-color: transparent; }
.top-btn::-webkit-details-marker { display: none; }
.top-btn:hover, .view-quick[open] > .top-btn { background: var(--panel-2); color: var(--ink); }
.top-btn .ic { width: 22px; height: 22px; }
.view-quick { position: relative; flex: 0 0 auto; }
.view-quick .vq-dark { display: none; }
html[data-theme="dark"] .view-quick .vq-light { display: none; }
html[data-theme="dark"] .view-quick .vq-dark { display: block; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .view-quick .vq-light { display: none; }
  html:not([data-theme="light"]) .view-quick .vq-dark { display: block; }
}
.vq-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: 300px; max-width: calc(100vw - 20px); display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow-lg); }
.vq-title { margin: 2px 2px 0; font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.vq-seg { display: grid; gap: 6px; }
.vq-seg-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.vq-seg button { min-height: 64px; padding: 8px 4px; flex-direction: column; gap: 4px; border-radius: 12px; background: var(--panel-2); border-color: transparent; font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.vq-seg button .ic { width: 20px; height: 20px; }
.vq-seg button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.vq-seg .fq-a { height: 22px; display: grid; place-items: center; font-weight: 800; line-height: 1; }
.vq-seg .fq-a.base { font-size: 15px; } .vq-seg .fq-a.lg { font-size: 19px; } .vq-seg .fq-a.xl { font-size: 23px; }
.vq-menu .fq-status { margin: 0 2px; font-size: 13px; color: var(--muted); }
.vq-menu .fq-status:empty { display: none; }
.vq-more { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 10px; margin-top: 2px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 14px; font-weight: 600; text-decoration: none; }
.vq-more:hover { color: var(--accent); }
@media (max-width: 699px) {
  .top-btn { width: 40px; height: 40px; }
  .vq-menu { position: fixed; left: 10px; right: 10px; top: auto; bottom: calc(76px + env(safe-area-inset-bottom)); width: auto; max-width: none; }
}
.ic { flex: 0 0 auto; vertical-align: middle; }
