/* 画面共通のデザイン. 色はここの変数で決め、ダークモードでは差し替える */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: #e4e7ef;
  --text: #171a21;
  --muted: #687083;
  --faint: #a3a9b8;
  --accent: #5b5bf0;
  --accent-2: #8b5cf6;
  --accent-soft: #ececfe;
  /* アクセント色の文字と、アクセント色の上に載せる文字. テーマカラーを変えると app/branding.py が読める色にする */
  --accent-text: var(--accent);
  --on-accent: #fff;
  /* 背景と上のバー、それぞれの上に載せる文字. 変えると app/branding.py が読める色にする */
  --bar: color-mix(in srgb, var(--surface) 80%, transparent);
  --on-bar: var(--text);
  --on-bg: var(--text);
  --on-bg-muted: var(--muted);
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --success: #1f9d66;
  --success-soft: #e6f6ee;
  --warn: #d97706;
  --shadow: 0 1px 2px rgb(16 24 40 / .04), 0 8px 24px rgb(16 24 40 / .06);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1016;
    --surface: #161922;
    --surface-2: #1d212c;
    --border: #2a2f3d;
    --text: #e8eaf0;
    --muted: #9aa1b2;
    --faint: #626a7d;
    --accent: #8183ff;
    --accent-2: #a78bfa;
    --accent-soft: #23244a;
    --danger: #ff6b6f;
    --danger-soft: #3a1c1f;
    --success: #3ccf8e;
    --success-soft: #14301f;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* display を指定した要素でも hidden 属性で隠れるようにする */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); }

/* 上部バー */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bar);
  color: var(--on-bar);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 880px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent);
}
.brand { min-width: 0; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 600px) {
  .topbar-inner { flex-wrap: wrap; }
  .brand { max-width: 100%; }
  .tabs { max-width: 100%; overflow-x: auto; }
  .tabs a { white-space: nowrap; }
}
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.tabs a {
  text-decoration: none; color: var(--muted); font-size: .85rem; font-weight: 600;
  padding: 6px 14px; border-radius: 999px; transition: background .15s, color .15s;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .08); }

.container { max-width: 880px; margin: 0 auto; padding: 28px 16px 64px; }
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 1.6rem; letter-spacing: -.02em; margin: 0 0 4px; color: var(--on-bg); }
.page-head p { color: var(--on-bg-muted); margin: 0; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ボタン */
.btn {
  font: inherit; font-size: .9rem; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid transparent; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  transition: transform .1s, background .15s, box-shadow .15s, opacity .15s;
}
.btn:hover { background: var(--border); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-primary {
  color: var(--on-accent); background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent), var(--accent-2)); filter: brightness(1.07); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.07); }
.icon-btn {
  width: 34px; height: 34px; padding: 0; border-radius: 10px; border: none; cursor: pointer;
  display: inline-grid; place-items: center; background: transparent; color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.confirm { background: var(--danger); color: #fff; width: auto; padding: 0 12px; font: inherit; font-size: .8rem; font-weight: 600; }
svg { flex-shrink: 0; }

/* トースト通知 */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; font-size: .88rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  animation: toast-in .25s ease-out;
}
.toast.ok svg { color: var(--success); }
.toast.error svg { color: var(--danger); }
.toast.leaving { animation: toast-out .2s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

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

/* ON / OFF の切り替え */
.switch { position: relative; width: 52px; height: 30px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch input:disabled { cursor: default; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--border); transition: background .2s; pointer-events: none; }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .2s;
}
.switch input:checked + span { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.switch input:checked + span::after { transform: translateX(22px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + span { opacity: .45; }
