  :root {
    --ink: #18203a;        /* 見出しパネル・文字 */
    --ink-2: #2a3563;
    --paper: #edf0f7;      /* 背景 */
    --surface: #ffffff;
    --line: #dfe3ee;
    --sub: #67708a;
    --accent: #4f5bd5;     /* 操作色 */
    --over: #e5484d;       /* 期限切れ */
    --today: #ee9b12;      /* 今日 */
    --soon: #129db3;       /* 3日以内 */
    --ok: #1f9d68;
    --num: "Outfit", "Zen Kaku Gothic New", sans-serif;
    --r-lg: 22px; --r-md: 14px; --r-sm: 9px;
  }
  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html, body { margin: 0; background: var(--paper); color: var(--ink);
    font-family: "Zen Kaku Gothic New", -apple-system, "Hiragino Sans", sans-serif; font-size: 15px; line-height: 1.5; }
  button { font: inherit; color: inherit; cursor: pointer; }
  button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px; }
  .hidden { display: none !important; }

  .app { max-width: 980px; margin: 0 auto; padding: 0 16px 150px; }

  /* ヘッダー */
  .top { display: flex; align-items: center; gap: 10px; padding: calc(18px + env(safe-area-inset-top)) 4px 12px; }
  .top h1 { flex: 1; margin: 0; font-size: 22px; font-weight: 700; letter-spacing: .02em; }
  .icon-btn { border: 0; background: var(--surface); width: 38px; height: 38px; border-radius: 50%;
    display: grid; place-items: center; color: var(--sub); }
  .busy { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--sub); }
  .busy i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }
  @keyframes pulse { 50% { opacity: .25; } }

  /* ===== 今日：日付パネル ===== */
  .mast { position: relative; overflow: hidden; background: var(--ink); color: #fff;
    border-radius: var(--r-lg); padding: 22px 22px 20px; margin-bottom: 22px; }
  .mast::after { content: ""; position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%;
    background: radial-gradient(circle, rgba(111,125,255,.45), transparent 70%); pointer-events: none; }
  .mast .date { display: flex; align-items: baseline; gap: 12px; position: relative; }
  .mast .md { font-family: var(--num); font-weight: 700; font-size: 46px; line-height: 1; letter-spacing: -.01em; }
  .mast .md small { font-size: 26px; font-weight: 600; opacity: .55; margin: 0 2px; }
  .mast .wd { font-size: 15px; opacity: .75; }
  .mast .stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; position: relative; }
  .stat { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 10px; border-radius: 99px;
    background: rgba(255,255,255,.08); font-size: 13px; }
  .stat b { font-family: var(--num); font-size: 17px; font-weight: 600; }
  .stat .d { width: 8px; height: 8px; border-radius: 50%; }
  .stat.zero { opacity: .45; }
  /* プロジェクト別の未完了タスク量 */
  .load { margin-top: 18px; position: relative; }
  .load .track { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: rgba(255,255,255,.1); gap: 2px; }
  .load .track span { display: block; height: 100%; }
  .load .legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 12px; opacity: .85; }
  .load .legend span { display: inline-flex; align-items: center; gap: 6px; }
  .load .legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
  .load .caption { font-size: 12px; opacity: .6; margin-bottom: 8px; }

  .cols { display: grid; gap: 0 22px; }
  @media (min-width: 900px) { .cols { grid-template-columns: 340px 1fr; align-items: start; } }

  /* ===== セクション ===== */
  .sec { margin: 0 0 22px; }
  .sec-h { display: flex; align-items: center; gap: 8px; margin: 0 6px 8px; font-size: 14px; font-weight: 700; }
  .sec-h .d { width: 10px; height: 10px; border-radius: 3px; }
  .sec-h .n { font-family: var(--num); font-weight: 600; color: var(--sub); font-size: 13px; }
  .list { background: var(--surface); border-radius: var(--r-md); overflow: hidden; }
  .sec.over .list { box-shadow: inset 3px 0 0 var(--over); }
  .empty { color: var(--sub); text-align: center; padding: 18px 12px; font-size: 13px; margin: 0; }

  /* 予定 */
  .ev { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .ev:last-child { border-bottom: 0; }
  .ev .time { width: 50px; flex: none; font-family: var(--num); font-size: 14px; font-weight: 600; color: var(--accent); line-height: 1.3; }
  .ev .time small { display: block; font-weight: 400; color: var(--sub); font-size: 12px; }
  .ev .time.allday { font-family: inherit; font-size: 12px; }
  .ev .loc { font-size: 12px; color: var(--sub); }

  /* タスク行 */
  .task { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
  .task:last-child { border-bottom: 0; }
  .task:hover { background: #f8f9fc; }
  .chk { appearance: none; -webkit-appearance: none; flex: none; width: 22px; height: 22px; margin: 0; border-radius: 50%;
    border: 2px solid var(--pc, var(--accent)); background: #fff; cursor: pointer; display: grid; place-items: center; transition: background .15s; }
  .chk:checked { background: var(--pc, var(--accent)); }
  .chk:checked::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }
  .task .body { flex: 1; min-width: 0; }
  .task .t { word-break: break-word; font-weight: 500; }
  .task.done .t { text-decoration: line-through; color: var(--sub); font-weight: 400; }
  .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 3px; font-size: 12px; color: var(--sub); align-items: center; }
  .pj { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; }
  .pj i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }
  .st { border-radius: 6px; padding: 0 7px; font-weight: 500; background: #e9ecff; color: #3d48b8; }
  .st.待ち { background: #fff1d6; color: #9a5b00; }
  .st.保留 { background: #eceef3; color: #586179; }
  .due { font-family: var(--num); font-weight: 600; }
  .due.over { color: var(--over); }
  .due.today { color: var(--today); }
  .flag { color: var(--over); font-weight: 700; margin-right: 6px; }

  /* ===== プロジェクト（開閉式） ===== */
  .tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 4px 12px; flex-wrap: wrap; }
  .link { border: 0; background: none; color: var(--accent); font-weight: 700; padding: 6px 0; }
  .toggle { font-size: 13px; color: var(--sub); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
  .toggle input { accent-color: var(--accent); }
  .pjs { display: grid; gap: 12px; }
  @media (min-width: 900px) { .pjs { grid-template-columns: 1fr 1fr; align-items: start; } }
  .pcard { background: var(--surface); border-radius: var(--r-md); overflow: hidden; }
  .pcard.arch { opacity: .55; }
  .phead { display: flex; align-items: center; gap: 12px; padding: 14px; cursor: pointer; width: 100%; border: 0; background: none; text-align: left; }
  .pmark { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: 17px; background: var(--pc); }
  .pname { flex: 1; min-width: 0; }
  .pname b { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pname small { color: var(--sub); font-size: 12px; }
  .pnums { display: flex; gap: 6px; align-items: center; }
  .pill { font-family: var(--num); font-weight: 600; font-size: 13px; min-width: 26px; text-align: center; padding: 2px 8px; border-radius: 99px;
    background: color-mix(in srgb, var(--pc) 14%, white); color: color-mix(in srgb, var(--pc) 75%, black); }
  .pill.over { background: #fde7e8; color: var(--over); }
  .chev { color: var(--sub); transition: transform .2s; }
  .pcard.open .chev { transform: rotate(180deg); }
  .pbody { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .22s ease; }
  .pcard.open .pbody { grid-template-rows: 1fr; }
  .pbody > div { overflow: hidden; }
  .pinner { border-top: 1px solid var(--line); background: color-mix(in srgb, var(--pc) 5%, white); }
  .pinner .task { border-bottom-color: color-mix(in srgb, var(--pc) 12%, var(--line)); }
  .pinner .task:hover { background: color-mix(in srgb, var(--pc) 9%, white); }
  .pgroup { font-size: 12px; font-weight: 700; color: color-mix(in srgb, var(--pc) 70%, black); padding: 10px 14px 2px; }
  .pfoot { display: flex; justify-content: space-between; padding: 6px 10px; }
  .pfoot button { border: 0; background: none; padding: 8px 6px; font-size: 13px; font-weight: 700; color: color-mix(in srgb, var(--pc) 80%, black); }
  .pfoot .sub { color: var(--sub); font-weight: 500; }

  /* ===== 繰り返し ===== */
  .rec .rule { font-weight: 600; color: var(--ink-2); }
  .help { background: var(--surface); border-radius: var(--r-md); padding: 14px 16px; margin-top: 16px; font-size: 13px; color: var(--sub); }
  .help b { color: var(--ink); }
  .help ul { margin: 6px 0 0; padding-left: 18px; }

  /* ===== 下部ナビ ===== */
  .tabs { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom));
    display: flex; gap: 4px; padding: 5px; background: var(--ink); border-radius: 99px; z-index: 6;
    box-shadow: 0 10px 30px rgba(24,32,58,.28); }
  .tabs button { border: 0; background: none; color: rgba(255,255,255,.6); padding: 10px 18px; border-radius: 99px; font-weight: 700; font-size: 14px; white-space: nowrap; }
  .tabs button.on { background: #fff; color: var(--ink); }

  #fab { position: fixed; right: max(18px, calc(50% - 470px)); bottom: calc(84px + env(safe-area-inset-bottom));
    width: 58px; height: 58px; border-radius: 18px; border: 0; background: var(--accent); color: #fff;
    display: grid; place-items: center; box-shadow: 0 10px 24px rgba(79,91,213,.4); z-index: 7; }

  /* ===== モーダル ===== */
  .modal { position: fixed; inset: 0; background: rgba(24,32,58,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
  .sheet { background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
    border-radius: 22px 22px 0 0; padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); }
  @media (min-width: 700px) { .modal { align-items: center; } .sheet { border-radius: 22px; } }
  .sheet h3 { margin: 0 0 16px; font-size: 18px; }
  .f { margin-bottom: 14px; }
  .f > label, .f > .lb { display: block; font-size: 12px; font-weight: 700; color: var(--sub); margin-bottom: 6px; }
  .f input[type=text], .f input[type=date], .f input[type=number], .f select, .f textarea {
    width: 100%; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: var(--r-sm); font: inherit; font-size: 16px; background: #fbfcfe; color: var(--ink); }
  .f input:focus, .f select:focus, .f textarea:focus { border-color: var(--accent); outline: none; background: #fff; }
  .f textarea { min-height: 76px; resize: vertical; }
  .row2 { display: flex; gap: 10px; } .row2 > .f { flex: 1; min-width: 0; }
  .seg { display: flex; flex-wrap: wrap; gap: 6px; }
  .seg label { border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: 8px 13px; font-size: 14px; cursor: pointer; background: #fbfcfe; }
  .seg input { position: absolute; opacity: 0; pointer-events: none; }
  .seg label:has(input:checked) { border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 700; }
  .seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
  .seg.wide label { flex: 1; text-align: center; }
  .opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--r-sm); margin-bottom: 8px; cursor: pointer; }
  .opt:has(input:checked) { border-color: var(--accent); background: #f3f4ff; }
  .opt input[type=radio] { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
  .opt select { width: auto; padding: 6px 8px; border: 1.5px solid var(--line); border-radius: 8px; font: inherit; font-size: 16px; }
  .preview { background: var(--ink); color: #fff; border-radius: var(--r-sm); padding: 12px 14px; font-size: 13px; margin-bottom: 14px; }
  .preview b { display: block; font-size: 12px; opacity: .65; font-weight: 500; margin-bottom: 4px; }
  .preview .dates { font-family: var(--num); font-size: 15px; font-weight: 600; display: flex; flex-wrap: wrap; gap: 4px 14px; }
  .preview.err { background: #fde7e8; color: var(--over); }
  .swatch { display: flex; gap: 10px; flex-wrap: wrap; }
  .swatch label { width: 32px; height: 32px; border-radius: 10px; cursor: pointer; position: relative; }
  .swatch input { position: absolute; opacity: 0; }
  .swatch label:has(input:checked) { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); }
  .actions { display: flex; gap: 8px; margin-top: 20px; }
  .btn { flex: 1; padding: 13px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-weight: 700; }
  .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
  .btn.danger { color: var(--over); flex: 0 0 auto; padding: 13px 16px; }
  .note { font-size: 12px; color: var(--sub); margin: -4px 0 12px; }

  .toast { position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translateX(-50%);
    background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 14px; z-index: 20; max-width: 90vw; }

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