:root {
    color-scheme: dark;
    --bg: #10120f;
    --panel: #1b1e19;
    --text: #f0f3eb;
    --muted: #a3ab9c;
    --lime: #c6f67a;
    --line: rgba(255, 255, 255, .1);
  }
  
  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  
  body {
    margin: 0;
    background:
      radial-gradient(ellipse at 85% 0%, #273021 0, transparent 45%),
      var(--bg);
    color: var(--text);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    min-height: 100vh;
  }
  
  button, input, select { font: inherit; }
  
  button, input, select, summary {
    -webkit-tap-highlight-color: transparent;
  }
  
  button {
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #292e25;
    color: var(--text);
    padding: 9px 14px;
    cursor: pointer;
    touch-action: manipulation;
  }
  
  button:hover { background: #353d2d; }
  button:active { transform: scale(.97); }
  button:disabled { opacity: .4; cursor: default; }
  
  button:focus-visible,
  input:focus-visible,
  select:focus-visible,
  summary:focus-visible,
  [role="button"]:focus-visible {
    outline: 2px solid var(--lime);
    outline-offset: 3px;
  }
  
  input, select {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 11px;
    background: #11150f;
    color: var(--text);
    font-size: 16px;
  }
  
  input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
  }
  
  input::-webkit-inner-spin-button,
  input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }
  
  label {
    display: block;
    color: var(--muted);
    font-size: 13px;
  }
  
  label input, label select { margin-top: 7px; }
  h1, h2, p { margin: 0; }
  
  h1 {
    font-size: clamp(24px, 4vw, 34px);
    font-weight: 700;
    letter-spacing: -.05em;
  }
  
  h2 { font-size: 16px; font-weight: 600; }
  
  .app {
    max-width: 1040px;
    margin: auto;
    padding: 30px 24px calc(115px + env(safe-area-inset-bottom));
  }
  
  .header, .section-head, .toolbar, .setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  
  .header { align-items: flex-start; }
  
  .eyebrow {
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .14em;
  }
  
  .header .eyebrow { margin-bottom: 9px; }
  
  .badge {
    font-size: 10px;
    white-space: nowrap;
    border: 1px solid var(--line);
    border-radius: 30px;
    padding: 5px 10px;
    color: var(--muted);
  }
  
  .preview-note, .hint {
    color: var(--muted);
    font-size: 12px;
  }
  
  .preview-note { margin: 12px 0 20px; }
  .hint { margin-top: 12px; }
  .muted { color: var(--muted); font-size: 12px; }
  
  /* ガラス表現 */
  .glass {
    background: rgba(43, 49, 39, .82);
    border: 1px solid rgba(255, 255, 255, .18);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, .1),
      0 12px 40px #0005;
    -webkit-backdrop-filter: blur(24px) saturate(130%);
    backdrop-filter: blur(24px) saturate(130%);
  }
  
  /* タイマー */
  .timer {
    position: sticky;
    top: 12px;
    z-index: 5;
    border-radius: 24px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 24px;
  }
  
  .timer > div:first-child {
    display: flex;
    align-items: center;
    gap: 16px;
  }
  
  .clock {
    font-size: 32px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.04em;
    padding: 0 5px;
    border: 0;
    background: transparent;
  }
  
  .timer-actions { display: flex; gap: 6px; }
  .timer-actions button { background: #ffffff09; }
  .timer.running .clock { color: var(--lime); }
  
  .timer.finished {
    box-shadow: 0 0 0 2px var(--lime), 0 0 30px #c6f67a20;
  }
  
  /* 記録画面 */
  .toolbar { margin-bottom: 18px; }
  .toolbar label { max-width: 180px; }
  
  .selectors, .entry-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 18px;
  }
  
  .selectors {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  }
  
  .record-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
  }
  
  .card {
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 22px;
    border-radius: 24px;
    margin-bottom: 18px;
  }
  
  .section-head { margin-bottom: 18px; }
  
  .previous-sets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
  }
  
  .previous-set {
    border-radius: 14px;
    background: #ffffff05;
    padding: 12px;
  }
  
  .previous-set strong {
    display: block;
    margin: 5px 0 2px;
    font-size: 22px;
    font-variant-numeric: tabular-nums;
  }
  
  .previous-set small { color: var(--muted); font-size: 12px; }
  
  .set-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    gap: 12px;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    padding: 14px 0;
  }
  
  .set-row strong {
    font-variant-numeric: tabular-nums;
    font-size: 17px;
  }
  
  .set-row small {
    display: block;
    font-size: 11px;
    color: var(--muted);
  }
  
  .set-row .set-index {
    color: var(--lime);
    width: 26px;
    flex-shrink: 0;
  }
  
  .set-row .row-content {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  
  .empty { padding: 18px 0; font-size: 13px; color: var(--muted); }
  .entry .section-head { margin-bottom: 25px; }
  .live-dot { color: var(--lime); font-size: 11px; }
  .live-dot::before { content: "●"; margin-right: 6px; }
  
  .entry-fields { grid-template-columns: 1fr; gap: 22px; }
  
  .stepper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
  }
  
  .stepper input {
    text-align: center;
    margin: 0;
    height: 68px;
    font-size: 34px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }
  
  .stepper button {
    flex: 0 0 48px;
    height: 54px;
    font-size: 23px;
  }
  
  .primary {
    width: 100%;
    background: var(--lime);
    color: #15200b;
    font-weight: 700;
    min-height: 56px;
    margin-top: 18px;
    border: 0;
    border-radius: 17px;
  }
  
  .primary:hover { background: #d5ff98; }
  details { color: var(--muted); font-size: 13px; }
  summary { cursor: pointer; padding: 8px 0; }
  
  /* 下部ナビゲーション */
  .nav {
    position: fixed;
    bottom: calc(16px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    width: min(420px, calc(100% - 32px));
    padding: 6px;
    border-radius: 25px;
  }
  
  .nav button {
    display: grid;
    gap: 0;
    justify-items: center;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 11px;
    padding: 6px;
    border-radius: 19px;
  }
  
  .nav button span { font-size: 23px; line-height: 1.3; }
  
  .nav button.active {
    color: var(--lime);
    background: #c6f67a12;
  }
  
  /* 履歴・分析 */
  .stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  
  .stats strong {
    display: block;
    font-size: 38px;
    letter-spacing: -.04em;
    margin-top: 8px;
  }
  
  .stats small {
    font-size: 14px;
    margin-left: 6px;
    color: var(--muted);
  }
  
  .calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
  }
  
  .weekdays {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 10px;
  }
  
  .calendar button {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 2px;
    background: transparent;
    border: 1px solid transparent;
  }
  
  .calendar button.selected {
    background: #c6f67a18;
    border-color: #c6f67a70;
  }
  
  .calendar button.today { color: var(--lime); }
  .calendar small { height: 14px; font-size: 10px; color: var(--lime); }
  .section-head select { max-width: 200px; }
  
  .chart { width: 100%; height: 180px; overflow: visible; }
  .chart text { fill: var(--muted); font-size: 11px; }
  .chart .grid { stroke: var(--line); }
  
  .chart .trend {
    fill: none;
    stroke: var(--lime);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  
  .chart circle {
    fill: var(--lime);
    stroke: var(--panel);
    stroke-width: 3;
  }
  
  .chart .hit { fill: transparent; stroke: none; cursor: pointer; }
  
  .bars {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    height: 180px;
    padding-top: 20px;
  }
  
  .bar {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    font-size: 12px;
    color: var(--muted);
  }
  
  .bar i {
    display: block;
    width: min(100%, 44px);
    background: linear-gradient(var(--lime), #6c8e43);
    border-radius: 8px 8px 3px 3px;
    min-height: 2px;
    margin: 6px 0;
  }
  
  /* 設定 */
  .setting-row {
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
    margin-bottom: 12px;
  }
  
  .switch {
    width: 22px;
    min-height: 22px;
    accent-color: var(--lime);
    margin: 0;
  }
  
  .checks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 16px 0;
  }
  
  .checks label {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  
  .checks input {
    width: 18px;
    min-height: 18px;
    margin: 0;
    accent-color: var(--lime);
  }
  
  .inline-form { display: flex; gap: 8px; margin-top: 12px; }
  .inline-form input { flex: 1; min-width: 0; }
  
  /* ダイアログ・通知 */
  dialog {
    color: var(--text);
    background: #20251eee;
    border: 1px solid #ffffff25;
    border-radius: 26px;
    padding: 24px;
    width: min(440px, calc(100% - 32px));
    max-height: 85dvh;
    overflow: auto;
    box-shadow: 0 30px 100px #0008;
    -webkit-backdrop-filter: blur(30px);
    backdrop-filter: blur(30px);
  }
  
  dialog::backdrop {
    background: #0009;
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
  }
  
  dialog label { margin: 12px 0; }
  
  .danger {
    width: 100%;
    color: #ffaaa1;
    margin-top: 12px;
    background: transparent;
  }
  
  .toast {
    position: fixed;
    bottom: calc(105px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    width: max-content;
    max-width: calc(100% - 32px);
    border-radius: 18px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
  }
  
  .toast button {
    color: var(--lime);
    background: transparent;
    border: 0;
    padding: 0 5px;
  }
  
  .keyboard .nav { display: none; }
  .keyboard .toast { bottom: 12px; }
  
  /* スマートフォン */
  @media (max-width: 650px) {
    .app {
      padding: 22px 16px calc(110px + env(safe-area-inset-bottom));
    }
  
    .header { gap: 8px; }
    .badge { font-size: 9px; padding: 4px 7px; }
    .record-grid { grid-template-columns: 1fr; gap: 0; }
    .card { padding: 18px; border-radius: 21px; }
  
    .timer {
      padding: 10px 12px;
      border-radius: 20px;
      top: 8px;
      gap: 6px;
    }
  
    .timer > div:first-child { display: block; }
    .timer .eyebrow { display: block; font-size: 9px; }
    .clock { font-size: 28px; }
    .timer-actions { gap: 4px; }
    .timer-actions button { padding: 7px 9px; font-size: 12px; }
  
    .entry-fields {
      grid-template-columns: 1fr 1fr;
      gap: 14px;
    }
  
    .stepper { gap: 4px; }
  
    .stepper button {
      flex-basis: 32px;
      min-width: 32px;
      padding: 0;
      font-size: 20px;
    }
  
    .stepper input {
      padding: 5px 0;
      font-size: 27px;
      height: 60px;
    }
  
    .section-head select { max-width: 170px; }
    .stats strong { font-size: 32px; }
  }
  
  @media (prefers-reduced-motion: no-preference) {
    button { transition: background .15s, transform .15s; }
  }