:root {
  --bg: #f2f2f7; --card: #ffffff; --fill: rgba(120,120,128,.12); --sep: rgba(60,60,67,.18);
  --text: #000000; --text2: rgba(60,60,67,.6); --accent: #007aff; --green: #34c759; --warn: #ff9500;
  --sun: #ff3b30; --sat: #007aff;
  --hol-bg: rgba(140,120,190,.16); --hol-text: #6b57a0;
  --glass: rgba(242,242,247,.72);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --card: #1c1c1e; --fill: rgba(120,120,128,.24); --sep: rgba(84,84,88,.6);
    --text: #ffffff; --text2: rgba(235,235,245,.6); --accent: #0a84ff;
    --hol-bg: rgba(160,140,210,.28); --hol-text: #bdaee0; --glass: rgba(28,28,30,.7);
    --sun: #ff453a; --sat: #64a8ff;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.35 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", sans-serif; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }

/* ---- レイアウト ---- */
#app { max-width: 1100px; margin: 0 auto; padding: calc(var(--safe-t) + 8px) 16px calc(150px + var(--safe-b)); }
.glass { background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px); }
.compact { position: fixed; top: 0; left: 0; right: 0; z-index: 20; padding: calc(var(--safe-t) + 8px) 16px 8px; display: flex; align-items: center; justify-content: center; gap: 10px; opacity: 0; transform: translateY(-8px); pointer-events: none; transition: .22s; border-bottom: .5px solid var(--sep); }
.compact.on { opacity: 1; transform: none; pointer-events: auto; }
.compact b { font-size: 17px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; padding: 8px 4px 6px; }
.head h1 { margin: 0; font-size: 34px; letter-spacing: .02em; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 999px; background: var(--card); box-shadow: 0 0 0 .5px var(--sep), 0 2px 8px rgba(0,0,0,.06); max-width: 62%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill.warn { color: var(--warn); }

.cols { display: block; }
@media (min-width: 600px) {
  .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
  .bottombar { display: none !important; }
  #app { padding-bottom: calc(100px + var(--safe-b)); }
  .addwide { display: flex !important; }
}
.addwide { display: none; justify-content: flex-end; margin-top: 18px; }

/* ---- カード・行 ---- */
.sec { margin: 22px 0 8px 16px; font-size: 13px; color: var(--text2); letter-spacing: .02em; }
.card { background: var(--card); border-radius: 22px; padding: 2px 16px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 8px 0; }
.row + .row, .note + .row, .row + .note { border-top: .5px solid var(--sep); }
.note { font-size: 12.5px; color: var(--text2); padding: 10px 0; border-top: .5px solid var(--sep); }
.note.warn { color: var(--warn); }
.chip { background: var(--fill); border-radius: 999px; padding: 6px 14px; font-size: 17px; font-variant-numeric: tabular-nums; }
input.chip { border: 0; text-align: center; outline: none; min-width: 92px; }
input[type=time].chip { min-width: 0; }
input.num { border: 0; background: transparent; text-align: right; width: 110px; outline: none; font-variant-numeric: tabular-nums; }
input.txt { border: 0; background: transparent; text-align: right; flex: 1; min-width: 0; outline: none; }
select.chip { border: 0; appearance: none; -webkit-appearance: none; text-align: center; padding: 6px 14px; }
.step { display: inline-flex; background: var(--fill); border-radius: 999px; overflow: hidden; }
.step button { width: 46px; height: 34px; font-size: 22px; }
.step button + button { border-left: .5px solid var(--sep); }
.step button:disabled { opacity: .3; }
.sw { position: relative; width: 51px; height: 31px; flex: none; }
.sw input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; z-index: 2; }
.sw i { position: absolute; inset: 0; border-radius: 99px; background: rgba(120,120,128,.32); transition: .2s; }
.sw i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.25); transition: .2s; }
.sw input:checked + i { background: var(--green); }
.sw input:checked + i::after { transform: translateX(20px); }

/* ---- 結果 ---- */
.res .l { display: flex; flex-direction: column; } .res .l small { color: var(--text2); font-size: 12.5px; }
.res .amt { font-variant-numeric: tabular-nums; }
.total { padding: 12px 0 14px; border-top: .5px solid var(--sep); }
.total small { color: var(--text2); font-size: 14px; } .total .big { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- ボタン ---- */
.btn { white-space: nowrap; flex: none; background: var(--accent); color: #fff; font-weight: 600; font-size: 15px; border-radius: 999px; padding: 0 18px; min-height: 34px; display: inline-flex; align-items: center; gap: 6px; }
.btn.green { background: var(--green); }
.btn.plain { background: var(--fill); color: var(--text); }
.btn.danger { background: var(--fill); color: var(--sun); }

/* ---- 下部の固定バーとタブ ---- */
.bottombar { position: fixed; left: 0; right: 0; bottom: calc(62px + var(--safe-b)); z-index: 15; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px 10px; border-top: .5px solid var(--sep); }
.bottombar small { display: block; font-size: 12px; color: var(--text2); } .bottombar b { font-size: 22px; font-variant-numeric: tabular-nums; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; justify-content: center; gap: 0; padding: 6px 12px calc(6px + var(--safe-b)); border-top: .5px solid var(--sep); }
.tabs button { flex: 1; max-width: 220px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--text2); padding: 4px 0; border-radius: 14px; }
.tabs button svg { width: 26px; height: 26px; }
.tabs button.on { color: var(--accent); background: var(--fill); }

/* ---- 日付シート ---- */
.sheetbg { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; background: var(--card); border-radius: 28px 28px 0 0; padding: 16px 16px calc(20px + var(--safe-b)); animation: up .22s ease-out; }
@media (min-width: 600px) { .sheetbg { align-items: center; } .sheet { border-radius: 28px; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet .top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet .top h3 { margin: 0; font-size: 20px; }
.sheet .nav { display: flex; align-items: center; }
.sheet .nav button { width: 40px; height: 40px; font-size: 24px; }
.sheet .nav .btn { width: auto; height: 34px; font-size: 15px; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 4px; text-align: center; }
.grid .w { font-size: 12px; font-weight: 700; color: var(--text2); padding-bottom: 4px; }
.grid .d { height: 44px; display: flex; align-items: center; justify-content: center; margin: 0 auto; width: 44px; border-radius: 50%; font-size: 19px; }
.grid .sun { color: var(--sun); } .grid .sat { color: var(--sat); }
.grid .hol { background: var(--hol-bg); color: var(--hol-text); }
.grid .today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.grid .sel { background: var(--accent); color: #fff; box-shadow: none; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); margin-top: 10px; }
.legend i { width: 14px; height: 14px; border-radius: 50%; background: var(--hol-bg); }

.list .row { cursor: pointer; }
.list .sub { color: var(--text2); font-size: 12.5px; }
.tag { font-size: 11px; background: var(--hol-bg); color: var(--hol-text); border-radius: 6px; padding: 1px 6px; margin-left: 6px; }
.empty { text-align: center; color: var(--text2); padding: 40px 0; }
.toast { position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%); z-index: 50; background: rgba(40,40,44,.92); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; }
