:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #ebe6da;
  --text: #23262a;
  --muted: #6a6d70;
  --line: #ddd6c6;
  --accent: #0d6b63;
  --accent-text: #ffffff;
  --accent-soft: #dcefe9;
  --warn: #a8341f;
  --shadow: 0 1px 2px rgba(40, 34, 20, .06), 0 4px 14px rgba(40, 34, 20, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16191c;
    --surface: #1f2428;
    --surface-2: #2a3035;
    --text: #e9e6df;
    --muted: #a0a4a8;
    --line: #343b41;
    --accent: #5cc8b8;
    --accent-text: #0c2622;
    --accent-soft: #1d3a37;
    --warn: #ff9a85;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Noto Sans JP", Meiryo, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
body.modal-open { overflow: hidden; }
[hidden] { display: none !important; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ヘッダー */
.top { padding: calc(20px + env(safe-area-inset-top)) 0 6px; }
.date-line { margin: 0; color: var(--accent); font-weight: 700; letter-spacing: .04em; font-size: .95rem; }
.top h1 { margin: 0; font-size: 1.7rem; line-height: 1.3; font-weight: 800; letter-spacing: .01em; }
.page-title { font-size: 1.25rem; margin: 14px 0 10px; }

/* ウィジェット */
.w { margin-top: 26px; }
.w-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.w-head h2 { margin: 0; font-size: 1.08rem; font-weight: 800; padding-left: 10px; border-left: 4px solid var(--accent); line-height: 1.3; }
.w-sub { color: var(--muted); font-size: .85rem; }
.loading { color: var(--muted); padding: 18px 4px; font-size: .95rem; }
.note { background: var(--surface-2); border-radius: var(--radius); padding: 14px 16px; color: var(--muted); font-size: .95rem; }
.note p { margin: 0 0 8px; }
.note p:last-child { margin: 0; }
.credit { margin: 8px 2px 0; font-size: .75rem; color: var(--muted); }

/* カード */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 10px; box-shadow: var(--shadow); margin-bottom: 10px; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 6px; }
.chip { background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: 1px 10px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.src { color: var(--muted); font-size: .78rem; }
.card h3 { margin: 0 0 4px; font-size: 1.04rem; line-height: 1.5; font-weight: 700; overflow-wrap: anywhere; }
.card h3 a { color: var(--text); text-decoration-color: var(--line); }
.card h3 a:hover { color: var(--accent); }
.card-body { margin: 0; font-size: .95rem; color: var(--text); overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px -6px 0; border-top: 1px solid var(--line); padding-top: 6px; }
.act { background: none; border: 0; border-radius: 8px; padding: 8px 8px; min-height: 40px; font-size: .82rem; color: var(--muted); cursor: pointer; white-space: nowrap; }
.act:hover { background: var(--surface-2); color: var(--text); }
.act[aria-pressed="true"] { color: var(--accent); font-weight: 700; }
.act:disabled { opacity: .5; cursor: default; }
.ai-box { margin-top: 10px; padding: 10px 12px; background: var(--accent-soft); border-radius: 10px; font-size: .92rem; white-space: pre-wrap; }
.card textarea { width: 100%; margin-top: 10px; }

/* AIのまとめ */
.digest { background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); padding: 14px 16px; white-space: pre-wrap; font-size: .97rem; margin-bottom: 8px; }

/* 提案 */
.suggest { background: var(--accent-soft); border-radius: var(--radius); padding: 14px 16px; margin-top: 16px; }
.suggest p { margin: 0 0 10px; font-weight: 700; }

/* 天気 */
.wx-now { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 6px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.wx-icon { font-size: 3rem; line-height: 1; }
.wx-temp { font-size: 2.3rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.wx-temp small { font-size: 1rem; font-weight: 700; margin-left: 2px; }
.wx-label { color: var(--muted); font-size: .9rem; }
.wx-facts { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; font-size: .82rem; }
.wx-facts dt { color: var(--muted); font-size: .72rem; }
.wx-facts dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.wx-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.wx-day { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; font-size: .78rem; line-height: 1.5; font-variant-numeric: tabular-nums; }
.wx-dow { font-weight: 700; }
.wx-di { font-size: 1.25rem; line-height: 1.4; }
.wx-hi { font-weight: 700; }
.wx-lo, .wx-pop { color: var(--muted); }
@media (max-width: 460px) {
  .wx-now { grid-template-columns: auto 1fr; }
  .wx-facts { grid-column: 1 / -1; grid-template-columns: repeat(4, auto); justify-content: space-between; border-top: 1px solid var(--line); padding-top: 8px; }
  .wx-day { font-size: .72rem; }
}

/* ボタン・入力 */
.btn { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; min-height: 44px; cursor: pointer; font-weight: 700; }
.btn:hover { border-color: var(--accent); }
.btn.small { padding: 6px 12px; min-height: 38px; font-size: .88rem; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { background: transparent; color: var(--warn); border-color: var(--warn); }
.btn.more { width: 100%; }
.btn:disabled { opacity: .4; cursor: default; }
input[type="text"], input[type="url"], input[type="search"], input[type="password"], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-height: 42px; min-width: 0; flex: 1; width: 100%;
}
textarea { min-height: 0; resize: vertical; line-height: 1.6; font-size: .92rem; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.row.wrap { flex-wrap: wrap; }
.row .btn { flex: none; }
.stack { display: grid; gap: 8px; margin-top: 10px; }
.filters { margin: 12px 0; }
.hint { color: var(--muted); font-size: .85rem; margin: 8px 0 0; }
.grow { flex: 1; }

/* 設定 */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; scroll-margin-top: 12px; }
.panel h3 { margin: 0 0 4px; font-size: 1.02rem; }
.panel summary { cursor: pointer; font-weight: 700; }
.grow-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.grow-row:last-child { border-bottom: 0; }
.grow-row > span { font-size: .95rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex: none; }
.seg button { background: transparent; border: 0; border-left: 1px solid var(--line); padding: 6px 10px; min-height: 38px; font-size: .82rem; cursor: pointer; color: var(--muted); }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.wrow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.wrow:last-child { border-bottom: 0; }
.wrow input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.wrow label { flex: 1; cursor: pointer; }
.wrow small { display: block; color: var(--muted); font-size: .78rem; line-height: 1.4; }
.place-now { margin: 4px 0 0; font-weight: 700; }
.place-results { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ジャンル選択 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; min-height: 42px; cursor: pointer; font-size: .92rem; }
.chip-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 700; }
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preset { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; line-height: 1.5; }
.preset:hover { border-color: var(--accent); }
.preset span { color: var(--muted); font-size: .8rem; }
@media (max-width: 460px) { .presets { grid-template-columns: 1fr; } }

/* はじめの設定 */
.setup { position: fixed; inset: 0; z-index: 30; background: var(--bg); overflow-y: auto; padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); }
.setup-card { max-width: 640px; margin: 0 auto; }
.setup-step { margin: 8px 0 0; color: var(--accent); font-weight: 700; font-size: .85rem; letter-spacing: .04em; }
.setup-card h2 { margin: 2px 0 6px; font-size: 1.4rem; line-height: 1.4; }
.setup-lead { margin: 0 0 14px; color: var(--muted); font-size: .95rem; }
.setup-body h3 { font-size: .95rem; margin: 18px 0 8px; }
.setup-foot { display: flex; gap: 8px; align-items: center; margin-top: 24px; position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--line); }

/* 下のメニュー */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; max-width: 240px; background: none; border: 0; padding: 8px 4px 9px; min-height: 58px; font-size: .74rem; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1.3; }
.tabbar button span { font-size: 1.25rem; line-height: 1.2; }
.tabbar button[aria-current="page"] { color: var(--accent); font-weight: 700; }

/* お知らせ */
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 999px; font-size: .88rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 40; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
