/* =========================================================
   TASK MANAGEMENT SYSTEM  —  案E「透明ウィンドウ」
   ソードアート・オンラインの HUD が下敷き。
   ・アインクラッドの空を背景に、透けるガラスの板を重ねる
   ・角丸は使わない。板は薄い枠＋内側にもう一本の細い枠
   ・選択中はオレンジ、達成率のゲージは赤→黄→黄緑
   仕様は ../UIデザイン仕様_案E_20260906.pdf を見ること。
   ========================================================= */

:root {
  color-scheme: dark;

  /* ウィンドウの濃さ。SETTING で 0.30 / 0.52 / 0.74 に切り替える */
  --glass: 0.52;
  --blur: 14px;

  --edge: rgba(200, 230, 255, 0.42);
  --edge-2: rgba(200, 230, 255, 0.16);

  --ink: #eaf4fd;
  --ink-2: #a9c8de;
  --ink-3: #7d9db8;

  --accent: #f0991c;
  --accent-hi: #ffc25c;
  --accent-deep: #e0850c;

  /* 優先度＝SAOのカラーカーソル */
  --cur-hi: #f0402f;
  --cur-mid: #f5a01e;
  --cur-low: #f0d820;

  /* ゲージ（少ない=赤 → 中間=黄 → 多い=黄緑）。JS 側と同じ値 */
  --g-lo: #d6261e;
  --g-mid: #f0be18;
  --g-hi: #8dff0a;

  /* ランク。暗い背景なので明るい側を使う */
  --rank-s: #3aa9f7;
  --rank-a: #f0554f;
  --rank-b: #fba03c;
  --rank-c: #f7cf3a;
  --rk-s-1: #6fc7ff; --rk-s-2: #0b6bd8;
  --rk-a-1: #ff7b74; --rk-a-2: #cf2222;
  --rk-b-1: #ffb35c; --rk-b-2: #e0740f;
  --rk-c-1: #ffe25c; --rk-c-2: #d9ac06;

  --danger: #ff8078;
  --danger-line: rgba(240, 85, 79, 0.5);
  --danger-bg: rgba(224, 52, 42, 0.16);
  --success: #8dff0a;

  --sun: #ff8a7a;
  --sat: #6fc7ff;

  --shadow: 0 14px 36px -18px rgba(0, 0, 0, 0.9);
  --tab-space: 150px;    /* スマホでタブに隠れない余白 */
  --menu-gutter: 132px;  /* PCで左の縦タブに重ならないよう空ける幅 */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font: 500 14.5px/1.55 "Rajdhani", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: #05101c;
  min-height: 100vh;
  overflow-x: hidden;
  text-shadow: 0 1px 3px rgba(0, 12, 24, 0.55);
}

button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ===== 背景（アインクラッドの空） ===== */

.world { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.world::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(110% 65% at 62% 108%, #3f80ae 0%, transparent 58%),
    radial-gradient(80% 55% at 12% -10%, rgba(70, 140, 200, 0.32) 0%, transparent 62%),
    linear-gradient(180deg, #05101c 0%, #0d2135 48%, #1a3f5f 100%);
}
.world::after { content: ""; position: absolute; inset: 0; background: rgba(4, 12, 22, 0.42); }

/* ===== 板＝透明なウィンドウ ===== */

.hud {
  position: relative;
  background:
    linear-gradient(180deg, rgba(140, 195, 240, 0.13), rgba(8, 20, 34, 0.02)),
    rgba(8, 22, 38, var(--glass));
  border: 1px solid var(--edge);
  backdrop-filter: blur(var(--blur)) saturate(1.25);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.25);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.hud::before {
  content: ""; position: absolute; inset: 4px;
  border: 1px solid var(--edge-2); pointer-events: none;
}

/* ===== 上のバー ===== */

.appbar {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  /* 本文（.stage）の板と左右の端をそろえる */
  width: calc(100% - 52px); max-width: 1128px;
  margin: 16px auto 0;
  padding: 10px 16px;
}
.appbar h1 {
  display: flex; align-items: center; gap: 11px;
  font-size: 16px; font-weight: 600; letter-spacing: 0.16em; color: #fff;
}
.appbar h1 i { width: 3px; height: 17px; background: var(--accent); flex: none; }
.appbar-right { display: flex; align-items: center; gap: 10px; }

.install-button {
  font-size: 10px; font-weight: 700; letter-spacing: 0.16em;
  padding: 7px 13px; color: var(--accent-hi);
  background: rgba(240, 153, 28, 0.14); border: 1px solid rgba(240, 153, 28, 0.5);
}
.install-button:hover { background: rgba(240, 153, 28, 0.26); }

.chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 5px;
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--edge-2);
}
.chip:hover { border-color: var(--edge); }
.chip-photo, .chip-initial {
  width: 24px; height: 24px; flex: none;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; letter-spacing: 0;
  color: #23384a; background: linear-gradient(160deg, var(--accent-hi), var(--accent-deep));
  object-fit: cover;
}
.chip-state { font-size: 9.5px; font-weight: 700; letter-spacing: 0.14em; color: var(--ink-2); white-space: nowrap; }

/* 同期のランプ */
.sync-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--ink-3); }
.sync-dot.is-ok { background: var(--success); box-shadow: 0 0 8px -1px var(--success); }
.sync-dot.is-busy { background: var(--accent-hi); box-shadow: 0 0 8px -1px var(--accent); }
.sync-dot.is-off { background: var(--ink-3); }
.sync-dot.is-error { background: var(--danger); box-shadow: 0 0 8px -1px var(--danger); }

/* ===== 本文の器 ===== */

.stage { position: relative; z-index: 2; padding: 18px 26px 60px; max-width: 1180px; margin: 0 auto; }

/* PCでは左の縦タブのぶんだけ本文全体を右へ寄せる（タブと重ならないように） */
@media (min-width: 901px) {
  body { padding-left: var(--menu-gutter); }
  .toast { left: calc(50% + var(--menu-gutter) / 2); }

  /* 上のバーは左のタブの上まで伸ばして、画面の横幅いっぱいに置く */
  .appbar {
    width: auto; max-width: none;
    margin: 0 0 0 calc(var(--menu-gutter) * -1);
    padding: 12px 28px;
    border-width: 0 0 1px;
  }
  .appbar::before { inset: auto 0 3px; border-width: 0 0 1px; }
  .stage { padding-top: 22px; }
}

.view { display: block; }
.vhead { padding: 0 2px 14px; }
.vhead h2 { font-size: 26px; font-weight: 300; letter-spacing: 0.14em; color: #fff; }

/* ===== 日付ナビ ===== */

.date-nav { display: flex; align-items: center; gap: 8px; padding: 4px 2px 14px; }
.date-nav-center { display: flex; align-items: center; }
.date-nav-arrow {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  font-size: 20px; line-height: 1; color: var(--ink-3);
}
.date-nav-arrow:hover { color: var(--accent-hi); }
.current-date-label {
  font-size: 23px; font-weight: 300; letter-spacing: 0.1em; color: #fff; white-space: nowrap;
}
.jump-today {
  margin-left: auto;
  font-size: 10px; font-weight: 700; letter-spacing: 0.18em;
  padding: 7px 15px; color: var(--ink-2);
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--edge-2);
}
.jump-today:hover { color: #fff; border-color: var(--edge); }
.cal-nav { justify-content: center; padding: 2px 0 12px; }

/* ===== ステータス窓 ===== */

.score-panel { padding: 18px 22px; margin-bottom: 22px; }
.status-top { display: flex; align-items: center; gap: 20px; }

/* ランクの六角形 */
.rank { position: relative; width: 78px; height: 88px; flex: none; }
.rank svg { width: 100%; height: 100%; display: block; stroke: none;
  filter: drop-shadow(0 0 7px var(--rank-glow, transparent)); }
/* 外周の線はランクの色に合わせる（--rank-line で1か所にまとめる） */
.rank .sk { stroke: var(--rank-line, var(--ink-3)); stroke-width: 2; stroke-opacity: 1; }
.rank .cap {
  position: absolute; left: 0; right: 0; top: 18px;
  text-align: center; font-size: 9px; font-weight: 700; letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.85);
}
.rank .let {
  position: absolute; left: 0; right: 0; top: 28px;
  text-align: center; font-size: 34px; font-weight: 700; line-height: 1; color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}
.rank .g1 { stop-color: var(--rk-c-1); }
.rank .g2 { stop-color: var(--rk-c-2); }
.rank.rank-s { --rank-line: var(--rk-s-1); --rank-glow: rgba(111, 199, 255, 0.55); }
.rank.rank-a { --rank-line: var(--rk-a-1); --rank-glow: rgba(255, 123, 116, 0.55); }
.rank.rank-b { --rank-line: var(--rk-b-1); --rank-glow: rgba(255, 179, 92, 0.55); }
.rank.rank-c { --rank-line: var(--rk-c-1); --rank-glow: rgba(255, 226, 92, 0.55); }
.rank.rank-none { --rank-line: var(--ink-3); --rank-glow: rgba(125, 157, 184, 0.30); }
.rank.rank-s .g1 { stop-color: var(--rk-s-1); } .rank.rank-s .g2 { stop-color: var(--rk-s-2); }
.rank.rank-a .g1 { stop-color: var(--rk-a-1); } .rank.rank-a .g2 { stop-color: var(--rk-a-2); }
.rank.rank-b .g1 { stop-color: var(--rk-b-1); } .rank.rank-b .g2 { stop-color: var(--rk-b-2); }
.rank.rank-c .g1 { stop-color: var(--rk-c-1); } .rank.rank-c .g2 { stop-color: var(--rk-c-2); }
.rank.rank-none .g1 { stop-color: #5d7690; } .rank.rank-none .g2 { stop-color: #2b3f52; }

@keyframes rank-pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.22); }
  100% { transform: scale(1); }
}
.rank.is-promoted { animation: rank-pop 0.5s cubic-bezier(0.22, 1, 0.36, 1); }

@keyframes panel-flash {
  0% { box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.22); }
  30% { box-shadow: 0 0 40px -6px var(--accent), inset 0 1px 0 rgba(255,255,255,0.5); }
  100% { box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.22); }
}
.score-panel.is-celebrating { animation: panel-flash 1.1s ease-out; }

/* 名前・ゲージ・タスク数 */
.meter { flex: 1; min-width: 0; }
.pname {
  font-size: 22px; font-weight: 700; letter-spacing: 0.16em; color: #fff;
  line-height: 1.1; margin-bottom: 5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mrow { display: flex; align-items: center; gap: 11px; }
.mval { min-width: 76px; text-align: right; font-size: 16px; font-weight: 700; white-space: nowrap; color: #fff; }
.mval b { font-size: 22px; font-weight: 300; }
.mval .rate-unit { font-size: 12px; color: var(--ink-3); }
.mfoot {
  display: flex; align-items: baseline; justify-content: space-between; gap: 18px;
  margin-top: 10px; max-width: 760px; flex-wrap: wrap;
}
.mfoot .left { display: flex; align-items: baseline; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.14em; color: var(--ink-2); }
.mfoot .left b { font-size: 18px; color: #fff; letter-spacing: 0; }
.mfoot .hint { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; color: var(--ink-2); margin: 0; }

/* =========================================================
   HPバー
   上辺は水平、下辺だけ 52% で斜めに上がって細くなる。右端は下側を斜めに切る。
   枠は 白1px → グレー #565653 1px → 黒地 → 中身 を 1px ずつ内側にずらして作る。
   --thin は「％」ではなく「上端からの px」で持つこと。％だと層を内側に入れても
   線が 0.1px しか動かず、白枠が隠れて段差と細い側の下に線が出ない。
   ========================================================= */

.gauge {
  position: relative;
  flex: 1; min-width: 0; max-width: 760px;
  height: 26px;      /* 根元（太い側）の高さ */
  --step: 52%;       /* 下辺が上がり始める位置 */
  --slope: 6px;      /* 段差の斜めの横幅。実物は 縦:横 = 2:1 */
  --thin: 14px;      /* 細い側の下辺。上端からの距離 */
  --tip: 10px;       /* 右端の斜めカットの横幅 */
  background: rgba(240, 248, 255, 0.94);
}
.gauge, .gauge::before, .gauge::after, .gin {
  clip-path: polygon(
    0 0,
    100% 0,
    calc(100% - var(--tip)) var(--t),
    calc(var(--step) + var(--slope)) var(--t),
    var(--step) 100%,
    0 100%);
}
.gauge         { --t: var(--thin); }
.gauge::before { --t: calc(var(--thin) - 2px); }
.gauge::after  { --t: calc(var(--thin) - 4px); }
.gin           { --t: calc(var(--thin) - 6px); }
.gauge::before, .gauge::after { content: ""; position: absolute; }
.gauge::before { inset: 1px; background: #565653; }
.gauge::after { inset: 2px; background: rgba(4, 14, 25, 0.92); }
.gin { position: absolute; inset: 3px; z-index: 1; }
.score-bar-fill {
  display: block; height: 100%; width: 0;
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ステータス窓の下のチップ */
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.stat-chip {
  display: flex; align-items: baseline; gap: 6px;
  padding: 8px 14px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.14em; color: var(--ink-2);
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--edge-2);
}
.stat-chip b { font-size: 15px; color: #fff; letter-spacing: 0; }
.stat-chip.ranks { gap: 8px; }
.stat-chip.ranks > span { display: flex; align-items: center; gap: 5px; }
.rank-pill {
  width: 17px; height: 17px; flex: none;
  display: grid; place-items: center;
  font-size: 9px; font-weight: 700; letter-spacing: 0; color: #16222e;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.rank-pill + b { margin-right: 4px; }
.rank-pill.rank-s { background: linear-gradient(160deg, var(--rk-s-1), var(--rk-s-2)); color: #fff; }
.rank-pill.rank-a { background: linear-gradient(160deg, var(--rk-a-1), var(--rk-a-2)); color: #fff; }
.rank-pill.rank-b { background: linear-gradient(160deg, var(--rk-b-1), var(--rk-b-2)); }
.rank-pill.rank-c { background: linear-gradient(160deg, var(--rk-c-1), var(--rk-c-2)); }

/* ===== 見出し ===== */

.section-head {
  display: flex; align-items: center; gap: 14px;
  margin: 26px 2px 12px;
}
.section-head h2 {
  font-size: 11px; font-weight: 700; letter-spacing: 0.28em; color: var(--ink-2);
  white-space: nowrap;
}
.section-head::after { content: ""; flex: 1; height: 1px; background: var(--edge-2); order: 1; }
.section-head .count-badge, .section-head button { order: 2; }
.count-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.16em; color: var(--ink-2); white-space: nowrap; }
.hint { font-size: 11px; font-weight: 500; letter-spacing: 0.04em; color: var(--ink-3); margin: 8px 2px 0; }
.empty-message {
  padding: 34px 18px; text-align: center;
  font-size: 12px; font-weight: 700; letter-spacing: 0.16em; color: var(--ink-3);
}
.empty-message small { display: block; margin-top: 8px; font-size: 10px; font-weight: 500; letter-spacing: 0.08em; }

/* ===== タスクの行 ===== */

.task-list, .manage-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.task-item {
  position: relative;
  display: flex; align-items: center; gap: 13px;
  padding: 12px 16px 12px 19px;
  background: rgba(8, 22, 38, calc(var(--glass) * 0.9));
  border: 1px solid var(--edge-2);
  backdrop-filter: blur(calc(var(--blur) * 0.7));
  -webkit-backdrop-filter: blur(calc(var(--blur) * 0.7));
  transition: border-color 0.2s, transform 0.2s;
}
.task-item::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--cur-mid);
}
.task-item.priority-3::before { background: var(--cur-hi); box-shadow: 0 0 12px -2px var(--cur-hi); }
.task-item.priority-2::before { background: var(--cur-mid); }
.task-item.priority-1::before { background: var(--cur-low); }
.task-item:hover { border-color: var(--edge); }
.task-item.is-done::before { background: var(--g-hi); }

.task-checkbox {
  appearance: none; -webkit-appearance: none;
  width: 22px; height: 22px; flex: none;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--edge);
  cursor: pointer; position: relative;
}
.task-checkbox:hover { border-color: var(--accent-hi); }
.task-checkbox:checked { background: linear-gradient(160deg, #a9ff4a, #4fbf12); border-color: #c7ff8a; }
.task-checkbox:checked::after {
  content: ""; position: absolute; left: 6px; top: 2px;
  width: 6px; height: 12px;
  border: solid #10301a; border-width: 0 2.5px 2.5px 0;
  transform: rotate(42deg);
}

.task-label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.task-title {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  font-size: 14.5px; font-weight: 600; color: #fff;
}
/* バッジ（CARRIED / DUE TODAY）は行の右端に寄せる */
.task-title > span:first-child { margin-left: auto; }
.task-meta { font-size: 10px; font-weight: 600; letter-spacing: 0.14em; color: var(--ink-3); }
.task-item.is-done .task-title { text-decoration: line-through; color: var(--ink-3); }

.carry-badge, .due-badge {
  flex: none; padding: 4px 9px;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.14em;
}
.carry-badge { color: var(--accent-hi); background: rgba(240, 153, 28, 0.16); border: 1px solid rgba(240, 153, 28, 0.45); }
.due-badge { color: var(--ink-2); background: rgba(255, 255, 255, 0.07); border: 1px solid var(--edge-2); }
.due-badge.is-urgent { color: #fff; background: rgba(240, 64, 47, 0.28); border-color: rgba(240, 64, 47, 0.7); }

.undo-button {
  flex: none; padding: 6px 12px;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.16em; color: var(--ink-2);
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--edge-2);
}
.undo-button:hover { color: #fff; border-color: var(--edge); }

@keyframes task-leave {
  to { opacity: 0; transform: translateX(26px); }
}
.task-item.is-leaving { animation: task-leave 0.24s ease-in forwards; }

/* 完了ぶん */
.done-section { margin-top: 18px; }
.done-section > summary {
  cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 2px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.24em; color: var(--ink-3);
  border-bottom: 1px solid var(--edge-2);
}
.done-section > summary::-webkit-details-marker { display: none; }
.done-section > summary::before { content: "+"; font-size: 15px; line-height: 1; color: var(--accent); }
.done-section[open] > summary::before { content: "−"; }
.done-section .task-list { margin-top: 10px; }

/* ===== ボタン ===== */

.primary-button, .secondary-button, .danger-button, .btn-out {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.18em;
  padding: 10px 20px; white-space: nowrap;
}
.primary-button {
  color: #2a1a02; background: linear-gradient(160deg, var(--accent-hi), var(--accent-deep));
  border: 1px solid #ffd490;
}
.primary-button:hover { box-shadow: 0 0 18px -3px rgba(240, 153, 28, 0.9); }
.secondary-button {
  color: var(--ink-2); background: rgba(255, 255, 255, 0.07); border: 1px solid var(--edge-2);
}
.secondary-button:hover { color: #fff; border-color: var(--edge); }
.danger-button, .btn-out {
  color: var(--danger); background: var(--danger-bg); border: 1px solid var(--danger-line);
}
.danger-button:hover, .btn-out:hover { color: #fff; background: rgba(224, 52, 42, 0.34); }
.primary-button.small, .secondary-button.small, .danger-button.small { padding: 7px 13px; font-size: 9.5px; }

/* ===== タスク一覧（管理） ===== */

.manage-item {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px 13px 19px; position: relative;
  background: rgba(8, 22, 38, calc(var(--glass) * 0.9));
  border: 1px solid var(--edge-2);
  backdrop-filter: blur(calc(var(--blur) * 0.7));
  -webkit-backdrop-filter: blur(calc(var(--blur) * 0.7));
}
.manage-item::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--cur-mid); }
.manage-item.priority-3::before { background: var(--cur-hi); }
.manage-item.priority-1::before { background: var(--cur-low); }
.manage-info { flex: 1; min-width: 0; }
.manage-title { font-size: 14.5px; font-weight: 600; color: #fff; }
.manage-meta { margin-top: 3px; font-size: 10px; font-weight: 600; letter-spacing: 0.14em; color: var(--ink-3); }
.manage-actions { display: flex; gap: 8px; flex: none; }

/* ===== 記録（カレンダー） ===== */

.home-calendar { padding: 18px 16px; }
.calendar-weekdays, .calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  max-width: 700px; margin-left: auto; margin-right: auto;   /* 広い画面でマスが伸びすぎないように */
}
.calendar-weekdays {
  margin-bottom: 8px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.16em; color: var(--ink-3); text-align: center;
}
.calendar-weekdays .sun { color: var(--sun); }
.calendar-weekdays .sat { color: var(--sat); }

.calendar-cell {
  aspect-ratio: 1 / 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1px solid transparent;
}
.calendar-cell:hover { border-color: var(--edge-2); }
.calendar-cell.is-selected { border-color: var(--edge); background: rgba(255, 255, 255, 0.05); }
.calendar-cell.is-today {
  border-color: var(--accent);
  box-shadow: 0 0 16px -3px var(--accent), inset 0 0 0 1px rgba(240, 153, 28, 0.3);
}
.calendar-cell.is-blank { pointer-events: none; }

.calendar-day { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; line-height: 1; color: var(--ink-2); }
.calendar-cell.is-today .calendar-day { color: var(--accent-hi); }
.calendar-cell.is-blank .calendar-day { color: var(--ink-3); opacity: 0.4; }

.day-ring {
  position: relative; width: 46px; height: 46px;
  display: grid; place-items: center;
}
.day-ring::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--ring-color, rgba(255, 255, 255, 0.11)) var(--progress, 0%), rgba(255, 255, 255, 0.14) 0);
  -webkit-mask: radial-gradient(closest-side, transparent 74%, #000 75%);
  mask: radial-gradient(closest-side, transparent 74%, #000 75%);
}
.calendar-cell.is-blank .day-ring::before { display: none; }
.calendar-cell.is-empty .day-ring::before {
  background: conic-gradient(rgba(255, 255, 255, 0.11) 100%, transparent 0);
}

.calendar-count {
  position: relative;
  font-size: 12px; font-weight: 600; line-height: 1; color: var(--ink-3);
}
.calendar-count.is-rank { font-size: 17px; font-weight: 700; color: #fff; }

/* ===== 記録タブ ===== */

.stat-row { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-tile { flex: 1; min-width: 200px; padding: 16px 18px; }
.stat-label { font-size: 10px; font-weight: 700; letter-spacing: 0.2em; color: var(--ink-3); }
.stat-value { display: flex; align-items: baseline; gap: 7px; margin-top: 6px; }
.stat-value span:first-child { font-size: 34px; font-weight: 300; line-height: 1; color: #fff; }
.stat-unit { font-size: 11px; font-weight: 700; letter-spacing: 0.16em; color: var(--ink-2); }
.stat-note { margin-top: 7px; font-size: 10px; font-weight: 600; letter-spacing: 0.1em; color: var(--ink-3); }

.rank-breakdown { padding: 14px 18px; display: flex; flex-direction: column; gap: 11px; }
.rank-row-item { display: flex; align-items: center; gap: 12px; }
.rank-chip {
  width: 22px; height: 22px; flex: none;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #16222e;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.rank-chip.rank-s { background: linear-gradient(160deg, var(--rk-s-1), var(--rk-s-2)); color: #fff; }
.rank-chip.rank-a { background: linear-gradient(160deg, var(--rk-a-1), var(--rk-a-2)); color: #fff; }
.rank-chip.rank-b { background: linear-gradient(160deg, var(--rk-b-1), var(--rk-b-2)); }
.rank-chip.rank-c { background: linear-gradient(160deg, var(--rk-c-1), var(--rk-c-2)); }
.rank-bar-wrap, .recent-bar-wrap {
  flex: 1; min-width: 0; height: 10px;
  background: rgba(4, 14, 25, 0.7); border: 1px solid var(--edge-2);
}
.rank-bar, .recent-bar { height: 100%; background: var(--ink-3); transition: width 0.4s ease; }
.rank-bar.rank-s, .recent-bar.rank-s { background: var(--rank-s); }
.rank-bar.rank-a, .recent-bar.rank-a { background: var(--rank-a); }
.rank-bar.rank-b, .recent-bar.rank-b { background: var(--rank-b); }
.rank-bar.rank-c, .recent-bar.rank-c { background: var(--rank-c); }
.rank-count, .recent-value {
  flex: none; min-width: 66px; text-align: right;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; color: var(--ink-2);
}

.recent-list { list-style: none; padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.recent-item { display: flex; align-items: center; gap: 12px; }
.recent-date { flex: none; min-width: 92px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; color: var(--ink-3); }

/* ===== 設定 ===== */

.set-group {
  display: flex; align-items: center; gap: 14px;
  margin: 22px 2px 10px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.28em; color: var(--ink-2);
}
.set-group::after { content: ""; flex: 1; height: 1px; background: var(--edge-2); }
.setbox { padding: 2px 18px; }
.set-row { display: flex; align-items: center; gap: 22px; padding: 17px 0; flex-wrap: wrap; }
.set-row + .set-row { border-top: 1px solid var(--edge-2); }
.set-txt { flex: 1; min-width: 190px; }
.set-txt b { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.16em; color: #fff; }
.set-txt > span { display: block; margin-top: 4px; font-size: 11px; font-weight: 500; color: var(--ink-3); }
.set-actions { display: flex; gap: 8px; flex: none; flex-wrap: wrap; }
.setbox .hint { padding-bottom: 16px; margin-top: 0; }

.seg { display: flex; flex: none; }
.seg button {
  font-size: 11px; font-weight: 700; letter-spacing: 0.18em;
  padding: 9px 19px; color: var(--ink-2);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--edge-2); border-right: 0;
}
.seg button:last-child { border-right: 1px solid var(--edge-2); }
.seg button:hover { color: #fff; }
.seg button.is-active {
  color: #2a1a02; background: linear-gradient(160deg, var(--accent-hi), var(--accent-deep));
  border-color: #ffd490;
}

.sync-account { display: flex !important; align-items: center; gap: 8px; flex-wrap: wrap; }
.sync-state-text { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; color: var(--ink-2); }
.sync-email { font-size: 11px; font-weight: 500; color: var(--ink-3); }
.sync-note { font-size: 11px; color: var(--ink-3); margin: 10px 0; }
.backup-message {
  margin: 0 0 16px; padding: 9px 13px;
  font-size: 11px; font-weight: 600;
  background: rgba(255, 255, 255, 0.07); border-left: 3px solid var(--ink-3);
}
.backup-message.is-success { color: var(--success); border-left-color: var(--success); }
.backup-message.is-error { color: var(--danger); border-left-color: var(--danger); }

/* ===== タブ（PCは左の縦並び） ===== */

.menu {
  position: fixed; z-index: 6;
  left: 24px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 50px;
}
.tab-button {
  position: relative; width: 54px; height: 54px; border-radius: 50%;
  display: grid; place-items: center;
  color: #2c5a7a;
  background: rgba(232, 244, 253, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.8);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.tab-button svg { width: 24px; height: 24px; }
.tab-button::after {
  content: ""; position: absolute; inset: 4px; border-radius: 50%;
  border: 1px solid rgba(23, 41, 59, 0.16); pointer-events: none;
}
.tab-button .ring {
  position: absolute; inset: -8px; border-radius: 50%;
  border: 1px solid rgba(190, 220, 245, 0.42); pointer-events: none;
}
.tab-button .tab-label {
  position: absolute; top: calc(100% + 14px); left: 50%; transform: translateX(-50%);
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.18em; color: var(--ink-2);
  white-space: nowrap;
}
.tab-button.is-active {
  color: #fff;
  background: linear-gradient(160deg, var(--accent-hi), var(--accent-deep));
  border-color: #ffd490;
  transform: translateX(12px) scale(1.1);
  box-shadow: 0 0 30px -2px rgba(240, 153, 28, 0.95), 0 8px 20px -8px rgba(0, 0, 0, 0.85);
}
.tab-button.is-active .ring {
  inset: -9px; border-color: rgba(255, 196, 90, 0.95);
  box-shadow: 0 0 18px -3px rgba(240, 153, 28, 0.95);
}
.tab-button.is-active .tab-label { color: #fff; }

/* ===== ダイアログ ===== */

.dialog-backdrop {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(3, 10, 18, 0.72);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  overflow-y: auto;
}
.dialog { width: 100%; max-width: 460px; padding: 24px 26px; margin: auto; }
.dialog h2 { font-size: 15px; font-weight: 700; letter-spacing: 0.2em; color: #fff; margin-bottom: 18px; }

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; margin-bottom: 6px; font-size: 10px; font-weight: 700; letter-spacing: 0.2em; color: var(--ink-2); }
.field input[type="text"], .field input[type="date"], .field select {
  width: 100%; padding: 10px 12px;
  color: #fff; background: rgba(4, 14, 25, 0.65);
  border: 1px solid var(--edge-2);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field select { appearance: none; -webkit-appearance: none; }
.field-hint { display: block; margin-top: 6px; font-size: 10.5px; color: var(--ink-3); }
.field-error { display: block; margin-top: 6px; font-size: 10.5px; color: var(--danger); }

.weekday-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.weekday-chip { position: relative; }
.weekday-chip input { position: absolute; opacity: 0; pointer-events: none; }
.weekday-chip span {
  display: block; padding: 8px 11px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em; color: var(--ink-2);
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--edge-2); cursor: pointer;
}
.weekday-chip input:checked + span {
  color: #2a1a02; background: linear-gradient(160deg, var(--accent-hi), var(--accent-deep)); border-color: #ffd490;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ===== LINK START（ログイン画面） ===== */

.login-screen {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(110% 65% at 62% 108%, #3f80ae 0%, transparent 58%),
    linear-gradient(180deg, #05101c 0%, #0d2135 48%, #1a3f5f 100%);
}
.login-card { width: 100%; max-width: 420px; padding: 34px 30px; text-align: center; }
.login-mark { width: 54px; height: 54px; margin: 0 auto 16px; color: var(--accent-hi); }
.login-mark svg { width: 100%; height: 100%; stroke-width: 1.3; }
.login-title { font-size: 30px; font-weight: 300; letter-spacing: 0.24em; color: #fff; }
.login-lead { margin: 14px 0 22px; font-size: 12px; line-height: 1.7; color: var(--ink-2); }
.login-lead b { color: #fff; }
.google-button {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 11px;
  padding: 13px 18px;
  font-size: 13px; font-weight: 600; color: #1f2b38;
  background: #fff; border: 1px solid #fff;
}
.google-button:hover { background: #eaf2fa; }
.google-button:disabled { opacity: 0.6; cursor: default; }
.google-mark { width: 19px; height: 19px; flex: none; }
.google-mark svg { width: 100%; height: 100%; stroke: none; }
.login-message { margin-top: 14px; font-size: 11px; color: var(--danger); }
.login-skip {
  margin-top: 18px; font-size: 10px; font-weight: 700; letter-spacing: 0.18em;
  color: var(--ink-3); text-decoration: underline;
}
.login-skip:hover { color: var(--ink); }

/* ===== アカウント画面 ===== */

.account-dialog { max-width: 480px; }
.account-card {
  display: flex; align-items: center; gap: 13px;
  padding: 14px; margin-bottom: 14px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--edge-2);
}
.account-photo, .account-initial {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 700; color: #23384a;
  background: linear-gradient(160deg, var(--accent-hi), var(--accent-deep));
  object-fit: cover;
}
.account-who { flex: 1; min-width: 0; }
.account-name { font-size: 14px; font-weight: 700; color: #fff; }
.account-email { margin-top: 2px; font-size: 11px; color: var(--ink-3); word-break: break-all; }
.account-badge {
  flex: none; padding: 4px 9px;
  font-size: 9px; font-weight: 700; letter-spacing: 0.16em; color: var(--success);
  background: rgba(141, 255, 10, 0.12); border: 1px solid rgba(141, 255, 10, 0.4);
}
.account-status { display: flex; align-items: center; gap: 8px; }
.account-state { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; color: var(--ink-2); }
.account-note, .account-lead { margin-top: 9px; font-size: 11px; line-height: 1.7; color: var(--ink-3); }
.account-lead { margin-bottom: 16px; }

.account-switch { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--edge-2); }
.account-switch-head { font-size: 10px; font-weight: 700; letter-spacing: 0.2em; color: var(--ink-3); margin-bottom: 10px; }
.account-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.account-row {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--edge-2);
}
.account-row.is-current { border-color: var(--accent); }
.account-pick { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 9px 11px; text-align: left; }
.account-avatar {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #23384a;
  background: linear-gradient(160deg, var(--accent-hi), var(--accent-deep));
  object-fit: cover;
}
.account-row-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.account-row-name { font-size: 12.5px; font-weight: 600; color: #fff; }
.account-row-email { font-size: 10.5px; color: var(--ink-3); word-break: break-all; }
.account-current-mark { flex: none; padding-right: 11px; font-size: 10px; font-weight: 700; letter-spacing: 0.14em; color: var(--accent-hi); }
.account-forget { flex: none; padding: 0 11px; font-size: 15px; line-height: 1; color: var(--ink-3); }
.account-forget:hover { color: var(--danger); }

/* ===== トースト ===== */

.toast {
  position: fixed; z-index: 25;
  left: 50%; bottom: 26px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px 12px 20px;
  background: rgba(8, 22, 38, 0.92); border: 1px solid var(--edge);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.toast-message { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; color: #fff; }
.toast-undo {
  padding: 6px 13px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.18em; color: var(--accent-hi);
  background: rgba(240, 153, 28, 0.16); border: 1px solid rgba(240, 153, 28, 0.5);
}
.toast-undo:hover { color: #fff; background: rgba(240, 153, 28, 0.3); }

/* =========================================================
   スマホ・タブレット
   ========================================================= */

@media (max-width: 900px) {
  .menu {
    left: 0; right: 0; top: auto; bottom: 0; transform: none;
    flex-direction: row; justify-content: center; gap: 22px;
    padding: 24px 0 calc(20px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(4,12,22,0) 0%, rgba(4,12,22,0.88) 40%, rgba(4,12,22,0.97) 100%);
  }
  .tab-button.is-active { transform: translateY(-13px) scale(1.1); }
  .tab-button .tab-label { top: calc(100% + 11px); font-size: 9px; letter-spacing: 0.14em; }

  /* 上のバーは板をやめて背景に溶かす */
  .appbar {
    width: auto; max-width: none;
    margin: 0;
    padding: calc(12px + env(safe-area-inset-top)) 14px 4px;
    background: none; border: 0; box-shadow: none;
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .appbar::before { display: none; }
  .appbar h1 { font-size: 13.5px; letter-spacing: 0.07em; }
  .chip-state { display: none; }
  .stage { padding: 10px 12px var(--tab-space); }

  .status-top { gap: 12px; }
  .rank { width: 64px; height: 72px; }
  .rank .let { font-size: 28px; top: 21px; }
  .rank .cap { top: 13px; font-size: 8px; }
  .pname { font-size: 18px; margin-bottom: 9px; }
  .gauge { height: 21px; --slope: 5px; --thin: 11px; --tip: 8px; }
  .mval { min-width: 62px; font-size: 13px; }
  .mval b { font-size: 18px; }
  .score-panel { padding: 14px 14px; }
  .current-date-label { font-size: 19px; }

  .home-calendar { padding: 14px 10px; }
  .calendar-weekdays, .calendar-grid { gap: 3px; }
  .calendar-cell { aspect-ratio: auto; padding: 5px 0; gap: 3px; }
  .day-ring { width: 34px; height: 34px; }
  .calendar-count.is-rank { font-size: 13px; }
  .calendar-count { font-size: 10px; }
  .calendar-day { font-size: 9px; }

  /* タスクの行は高さを詰めて、1画面に多く入るようにする */
  .task-list, .manage-list { gap: 5px; }
  .task-item { padding: 8px 12px 8px 15px; gap: 11px; }
  .task-label { gap: 1px; }
  .task-title { font-size: 13px; gap: 7px; }
  .task-meta { font-size: 9px; letter-spacing: 0.1em; }
  .task-checkbox { width: 19px; height: 19px; }
  .task-checkbox:checked::after { left: 5px; top: 2px; width: 5px; height: 10px; border-width: 0 2px 2px 0; }
  .carry-badge, .due-badge { padding: 3px 7px; font-size: 8.5px; letter-spacing: 0.1em; }
  .undo-button { padding: 5px 9px; font-size: 8.5px; letter-spacing: 0.12em; }
  /* TASKSタブの行。ボタンを小さくして、名前の幅を確保する */
  .manage-item { padding: 9px 11px 9px 15px; gap: 8px; }
  .manage-title { font-size: 13px; word-break: break-word; }
  .manage-meta { font-size: 9px; margin-top: 1px; }
  .manage-actions { gap: 6px; }

  /* ボタンはスマホでは一回り小さく */
  .primary-button, .secondary-button, .danger-button, .btn-out {
    padding: 8px 15px; font-size: 9.5px; letter-spacing: 0.14em;
  }
  .primary-button.small, .secondary-button.small, .danger-button.small {
    padding: 6px 10px; font-size: 9px; letter-spacing: 0.1em;
  }

  .vhead { padding-bottom: 8px; }
  .vhead h2 { font-size: 22px; }
  .section-head { margin: 18px 2px 10px; }

  .set-row { gap: 14px; }
  .toast { left: 12px; right: 12px; bottom: calc(var(--tab-space) - 26px); transform: none; }
}

/* タブが5つ入るように、狭い画面ではひと回り小さくする */
@media (max-width: 430px) {
  .menu { gap: 15px; }
  .tab-button { width: 46px; height: 46px; }
  .tab-button svg { width: 21px; height: 21px; }
  .tab-button::after { inset: 3px; }
  .tab-button .ring { inset: -6px; }
  .tab-button.is-active .ring { inset: -7px; }
  .tab-button .tab-label { font-size: 8.5px; letter-spacing: 0.1em; top: calc(100% + 9px); }
  /* 狭い画面ではタイトルが2行に折れるので、ひと回り小さくする */
  .appbar h1 { font-size: 11.5px; letter-spacing: 0.05em; gap: 8px; }
  .stage { padding-bottom: 138px; }
  .set-actions { width: 100%; }   /* .set-row は折り返すのでこれでよい */
}

/* 動きを減らす設定のときは、演出を止める */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
