﻿:root {
      --bg: #f3f5f4;
      --panel: #ffffff;
      --panel-muted: #edf1ee;
      --text: #182026;
      --text-muted: #5b6770;
      --line: #d1d9d4;
      --accent: #1f6f58;
      --accent-2: #154e3e;
      --warn: #c56a2d;
      --danger: #a23d3d;
      --ring-bg: #dbe5de;
      --shadow: 0 10px 26px rgba(20, 36, 30, 0.08);
      --focus: 0 0 0 3px rgba(31, 111, 88, 0.3);
      --radius: 14px;
      --radius-sm: 10px;
      --font: "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
    }

    body.high-contrast {
      --bg: #f4f4f4;
      --panel: #ffffff;
      --panel-muted: #efefef;
      --text: #000000;
      --text-muted: #1e1e1e;
      --line: #707070;
      --accent: #005a38;
      --accent-2: #003725;
      --warn: #934000;
      --danger: #7d0000;
      --ring-bg: #cbcbcb;
      --focus: 0 0 0 3px rgba(0, 90, 56, 0.45);
    }

    * { box-sizing: border-box; }

    html, body {
      margin: 0;
      min-height: 100%;
      background:
        radial-gradient(1200px 600px at 10% -10%, #ddece4 0%, transparent 55%),
        linear-gradient(140deg, #f3f5f4 0%, #eef2ef 45%, #f7f8f8 100%);
      color: var(--text);
      font-family: var(--font);
    }

    body.reduce-motion *,
    body.reduce-motion *::before,
    body.reduce-motion *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }

    .app {
      max-width: 1160px;
      margin: 0 auto;
      padding: 1rem;
      display: grid;
      gap: 1rem;
      min-height: 100vh;
      grid-template-rows: auto 1fr;
    }

    .topbar {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      padding: 0.75rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.75rem;
      flex-wrap: wrap;
    }

    .brand {
      display: grid;
      gap: 0.1rem;
    }

    .brand h1 {
      margin: 0;
      font-size: 1rem;
      letter-spacing: 0.08em;
      text-transform: uppercase;
    }

    .brand p {
      margin: 0;
      color: var(--text-muted);
      font-size: 0.86rem;
    }

    .quick-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 0.45rem;
    }

    .layout {
      display: grid;
      gap: 1rem;
      grid-template-columns: 1.2fr 1fr;
      align-items: start;
    }

    .panel {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      padding: 1rem;
    }

    .focus-console {
      display: grid;
      gap: 1rem;
    }

    .hero {
      position: relative;
      border-radius: var(--radius);
      border: 1px solid var(--line);
      background: linear-gradient(165deg, #fbfdfc 0%, #f2f6f3 100%);
      padding: 1rem;
      display: grid;
      gap: 0.75rem;
      justify-items: center;
      text-align: center;
      overflow: hidden;
      isolation: isolate;
    }

    .hero::after {
      content: "";
      position: absolute;
      inset: -80% -20% auto;
      height: 180%;
      background: radial-gradient(circle at 50% 50%, rgba(31, 111, 88, 0.09), transparent 55%);
      z-index: -1;
      transform: translateY(-36%);
      pointer-events: none;
    }

    .hero.warn {
      animation: pulseWarn 900ms ease-out 1;
    }

    @keyframes pulseWarn {
      0% { box-shadow: 0 0 0 0 rgba(197, 106, 45, 0.2); }
      40% { box-shadow: 0 0 0 18px rgba(197, 106, 45, 0.06); }
      100% { box-shadow: 0 0 0 0 rgba(197, 106, 45, 0); }
    }

    .timer-ring-wrap {
      position: relative;
      width: min(75vw, 320px);
      aspect-ratio: 1 / 1;
      display: grid;
      place-items: center;
    }

    .timer-ring {
      width: 100%;
      height: 100%;
      transform: rotate(-90deg);
    }

    .timer-ring circle {
      fill: none;
      stroke-width: 13;
      stroke-linecap: round;
    }

    .timer-ring .track { stroke: var(--ring-bg); }
    .timer-ring .progress {
      stroke: var(--accent);
      transition: stroke-dashoffset 260ms linear;
    }

    .time-core {
      position: absolute;
      display: grid;
      gap: 0.2rem;
      align-items: center;
      justify-items: center;
      text-align: center;
      padding: 0.5rem;
    }

    .time-value {
      margin: 0;
      font-size: clamp(2.4rem, 7vw, 4.2rem);
      line-height: 1;
      font-weight: 700;
      letter-spacing: 0.03em;
      font-variant-numeric: tabular-nums;
    }

    .time-sub {
      margin: 0;
      color: var(--text-muted);
      font-size: 0.95rem;
    }

    .timebar {
      width: 100%;
      height: 10px;
      border-radius: 999px;
      background: var(--ring-bg);
      overflow: hidden;
      display: none;
    }

    .timebar.show { display: block; }

    .timebar > span {
      display: block;
      height: 100%;
      width: 0;
      background: linear-gradient(90deg, var(--accent), #2a8f72);
      transition: width 250ms linear;
    }

    .controls {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 0.5rem;
    }

    .cue-row {
      display: flex;
      gap: 0.5rem;
      justify-content: center;
      flex-wrap: wrap;
    }

    .status-strip {
      display: flex;
      justify-content: center;
      gap: 0.6rem;
      flex-wrap: wrap;
      color: var(--text-muted);
      font-size: 0.92rem;
    }

    .task-card {
      display: grid;
      gap: 0.6rem;
      border: 1px solid var(--line);
      border-radius: var(--radius-sm);
      padding: 0.8rem;
      background: var(--panel-muted);
    }

    .task-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.6rem;
    }

    .task-title {
      margin: 0;
      font-size: 1.05rem;
      line-height: 1.2;
    }

    .muted {
      color: var(--text-muted);
      font-size: 0.92rem;
    }

    .input-row {
      display: grid;
      gap: 0.5rem;
      grid-template-columns: 1fr 1fr auto;
    }

    .step-list,
    .distraction-list,
    .task-list {
      margin: 0;
      padding: 0;
      list-style: none;
      display: grid;
      gap: 0.4rem;
    }

    .step-item,
    .distraction-item,
    .task-item {
      display: flex;
      gap: 0.45rem;
      align-items: center;
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 0.45rem 0.5rem;
      background: var(--panel);
    }

    .step-item input[type="text"] {
      flex: 1;
    }

    .dock {
      display: grid;
      gap: 0.5rem;
    }

    .dock-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.5rem;
      flex-wrap: wrap;
    }

    .chip {
      display: inline-flex;
      align-items: center;
      gap: 0.25rem;
      border: 1px solid var(--line);
      border-radius: 999px;
      padding: 0.2rem 0.5rem;
      font-size: 0.75rem;
      color: var(--text-muted);
      background: var(--panel);
    }

    .right-column {
      display: grid;
      gap: 1rem;
      align-content: start;
    }

    .metrics {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 0.5rem;
    }

    .metric {
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 0.6rem;
      background: var(--panel-muted);
    }

    .metric .val {
      margin: 0;
      font-size: 1.25rem;
      font-weight: 700;
      font-variant-numeric: tabular-nums;
    }

    .metric .lbl {
      margin: 0;
      color: var(--text-muted);
      font-size: 0.8rem;
    }

    .trend {
      display: grid;
      grid-template-columns: repeat(7, minmax(0, 1fr));
      gap: 0.3rem;
      align-items: end;
      min-height: 90px;
      margin-top: 0.4rem;
    }

    .trend .bar {
      background: linear-gradient(180deg, #81b7a2 0%, #2a8f72 100%);
      border-radius: 6px 6px 3px 3px;
      min-height: 4px;
    }

    .trend .day {
      text-align: center;
      font-size: 0.72rem;
      color: var(--text-muted);
      margin-top: 0.2rem;
    }

    button,
    input,
    textarea,
    select {
      font: inherit;
      color: inherit;
    }

    button,
    .button {
      border: 1px solid var(--line);
      border-radius: 10px;
      background: var(--panel);
      color: var(--text);
      padding: 0.55rem 0.7rem;
      cursor: pointer;
      min-height: 44px;
      transition: transform 120ms ease, background 120ms ease;
    }

    button:hover {
      background: #f7faf8;
    }

    button:active {
      transform: translateY(1px);
    }

    button.primary {
      border-color: var(--accent);
      background: var(--accent);
      color: #fff;
    }

    button.primary:hover {
      background: var(--accent-2);
    }

    button.warning {
      border-color: var(--warn);
      color: var(--warn);
    }

    button.ghost {
      background: transparent;
    }

    button.link {
      border: none;
      padding: 0;
      min-height: 0;
      background: transparent;
      text-decoration: underline;
      color: var(--accent-2);
      cursor: pointer;
    }

    input[type="text"],
    input[type="number"],
    textarea,
    select {
      border: 1px solid var(--line);
      border-radius: 10px;
      background: #fff;
      padding: 0.55rem 0.65rem;
      min-height: 44px;
      width: 100%;
    }

    textarea {
      min-height: 120px;
      resize: vertical;
    }

    label {
      display: grid;
      gap: 0.28rem;
      font-size: 0.9rem;
      color: var(--text-muted);
    }

    .field-inline {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      flex-wrap: wrap;
    }

    .toggle {
      display: inline-flex;
      align-items: center;
      gap: 0.35rem;
      border: 1px solid var(--line);
      border-radius: 999px;
      padding: 0.2rem 0.55rem;
      font-size: 0.85rem;
      color: var(--text-muted);
      min-height: 38px;
    }

    input[type="checkbox"] {
      width: 18px;
      height: 18px;
      accent-color: var(--accent);
    }

    .modal-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(7, 10, 9, 0.45);
      display: none;
      place-items: center;
      padding: 1rem;
      z-index: 50;
    }

    .modal-backdrop.show {
      display: grid;
    }

    .modal {
      width: min(760px, 96vw);
      max-height: 92vh;
      overflow: auto;
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: 0 18px 50px rgba(9, 18, 14, 0.32);
      padding: 1rem;
      display: grid;
      gap: 0.8rem;
    }

    .modal.small {
      width: min(440px, 96vw);
    }

    .modal-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.5rem;
    }

    .modal-head h2 {
      margin: 0;
      font-size: 1.05rem;
    }

    .grid-2 {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 0.5rem;
    }

    .grid-3 {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 0.5rem;
    }

    .modal-actions {
      display: flex;
      justify-content: flex-end;
      gap: 0.5rem;
      flex-wrap: wrap;
    }

    .shortcuts {
      margin: 0;
      padding: 0;
      list-style: none;
      display: grid;
      gap: 0.4rem;
    }

    .shortcuts li {
      display: flex;
      justify-content: space-between;
      border-bottom: 1px solid var(--line);
      padding-bottom: 0.3rem;
      gap: 0.5rem;
    }

    .guide-manual {
      border: 1px solid var(--line);
      border-radius: 10px;
      background: var(--panel-muted);
      padding: 0.75rem;
      display: grid;
      gap: 0.45rem;
    }

    .guide-manual h3 {
      margin: 0;
      font-size: 0.98rem;
    }

    .guide-steps {
      margin: 0;
      padding-left: 1.1rem;
      display: grid;
      gap: 0.35rem;
      font-size: 0.88rem;
      color: var(--text-muted);
      line-height: 1.4;
    }

    kbd {
      border: 1px solid var(--line);
      background: var(--panel-muted);
      border-bottom-width: 2px;
      border-radius: 6px;
      padding: 0.2rem 0.45rem;
      font-size: 0.8rem;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    }

    .toast-region {
      position: fixed;
      right: 1rem;
      bottom: 1rem;
      display: grid;
      gap: 0.45rem;
      z-index: 100;
      width: min(360px, 94vw);
    }

    .toast {
      border: 1px solid var(--line);
      background: var(--panel);
      box-shadow: var(--shadow);
      border-radius: 12px;
      padding: 0.55rem 0.65rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.5rem;
      font-size: 0.92rem;
    }

    .pt-tooltip {
      position: fixed;
      z-index: 130;
      max-width: min(300px, 92vw);
      border-radius: 10px;
      border: 1px solid rgba(0, 0, 0, 0.08);
      background: #14261f;
      color: #ffffff;
      padding: 0.46rem 0.62rem;
      font-size: 0.82rem;
      line-height: 1.35;
      box-shadow: 0 12px 30px rgba(7, 15, 12, 0.28);
      pointer-events: none;
      opacity: 0;
      transform: translateY(4px);
      transition: opacity 120ms ease, transform 120ms ease;
    }

    .pt-tooltip.show {
      opacity: 1;
      transform: translateY(0);
    }

    body.high-contrast .pt-tooltip {
      background: #000000;
      border-color: #000000;
      color: #ffffff;
    }

    .sr-only {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border: 0;
    }

    :focus-visible {
      outline: none;
      box-shadow: var(--focus);
    }

    @media (max-width: 980px) {
      .layout {
        grid-template-columns: 1fr;
      }

      .controls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .input-row {
        grid-template-columns: 1fr;
      }

      .metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .grid-2,
      .grid-3 {
        grid-template-columns: 1fr;
      }
    }
