* {
  box-sizing: border-box;
}
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: var(--app-bg, #000000);
  color: var(--app-text, #ffffff);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none; /* Prevents scroll bounce and pull-to-refresh */
}
body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
}
button, .btn-habit, .pin, .pin-sync-btn, .btn-control, .color-picker, .modal-btn, .type-btn {
  touch-action: manipulation; /* Prevents double-tap zoom delay */
}

    :root {
      --cell-diagonal-angle: 36.87deg;
      --cell-line-width: 1px;
      --field-max-width: 620px;
      --field-cell-min: 92px;
      --week-strip-color: rgba(93, 220, 190, 0.18);
      --view-tab-active-bg: rgba(38, 63, 112, 0.34);
      --view-tab-active-text: #9db7e8;
      --view-tab-hover-bg: rgba(70, 93, 140, 0.16);
    }
    .container {
      width: 100%;
      /* Adjust max-width below to tune desktop layout width */
      max-width: 1480px;
      margin: 0 auto;
      display: flex;
      flex-direction: column;
      gap: 1px;
    }
    
    /* Controls group - consistent 1px gaps */
    .controls-group {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    /* ===== HEADER - Progress Strips ===== */
    .header {
      display: flex;
      flex-direction: column;
      width: 100%;
      gap: 4px;
      padding: 0;
    }

    .progress-meta {
      position: relative;
      display: grid;
      grid-template-columns: minmax(128px, 0.8fr) minmax(0, 1.4fr) auto;
      align-items: center;
      column-gap: 10px;
      min-height: 20px;
      padding: 0 12px;
      color: var(--app-text, #fff);
      background:
        linear-gradient(90deg, rgba(255,255,255,0.012), transparent 44%, rgba(255,255,255,0.01)),
        var(--app-bg, #000);
      font-family: "Roboto Condensed", -apple-system, sans-serif;
      font-variant-numeric: tabular-nums;
    }

    .meta-primary,
    .meta-secondary,
    .meta-center {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .meta-primary {
      justify-self: start;
      text-transform: uppercase;
    }

    .meta-primary-pair {
      display: flex;
      align-items: center;
      gap: clamp(32px, 5.5vw, 86px);
      max-width: 100%;
    }

    .meta-primary-pair span {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .meta-center {
      justify-self: stretch;
      color: var(--app-text, #fff);
      text-align: center;
    }

    .meta-inspector {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
      color: var(--app-text, #ffffff);
      opacity: 0.38;
    }

    .meta-inspector[data-active="true"] {
      opacity: 0.92;
    }

    .timeline-inspector-dot {
      width: 7px;
      height: 7px;
      flex: 0 0 auto;
      border-radius: 999px;
      background: var(--timeline-info-color, #ffffff);
      box-shadow: 0 0 6px color-mix(in srgb, var(--timeline-info-color, #ffffff) 52%, transparent);
    }

    .timeline-inspector-text {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .meta-secondary {
      justify-self: end;
      text-align: right;
    }

    .meta-primary,
    .meta-secondary,
    .meta-center {
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.02em;
      opacity: 0.82;
    }
    
    .progress-strip {
      position: relative;
      width: 100%;
      height: 28px;
      background:
        linear-gradient(90deg, rgba(255,255,255,0.018), transparent 42%, rgba(255,255,255,0.012)),
        var(--app-bg, #000);
      box-shadow:
        inset -1px 0 0 rgba(255,255,255,0.28),
        inset 0 0 0 1px rgba(255,255,255,0.018);
      overflow: hidden;
    }

    .progress-strip::before {
      content: '';
      position: absolute;
      top: -3px;
      bottom: -3px;
      left: clamp(0%, var(--strip-progress, 0%), 100%);
      width: 12px;
      z-index: 4;
      pointer-events: none;
      background:
        linear-gradient(90deg, transparent 0 4px, var(--now-marker-color, rgba(255,255,255,0.96)) 4px 8px, transparent 8px 100%),
        rgba(7, 10, 16, 0.72);
      border: 1px solid color-mix(in srgb, var(--now-marker-color, #ffffff) 38%, transparent);
      border-radius: 3px;
      box-shadow:
        0 0 0 1px rgba(0,0,0,0.62),
        0 0 8px rgba(255,255,255,0.18);
      transform: translateX(-6px);
      animation: currentMarkerPulse 2.4s ease-in-out infinite;
    }

    .progress-strip[data-marker="off"]::before {
      display: none;
    }

    .timeline-info {
      min-height: 18px;
      padding: 0 12px;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      color: color-mix(in srgb, var(--timeline-info-color, var(--app-text, #ffffff)) 72%, var(--app-bg, #000000));
      background: var(--app-bg, #000000);
      font-family: "Roboto Condensed", -apple-system, sans-serif;
      font-size: 11px;
      font-weight: 700;
      font-variant-numeric: tabular-nums;
      letter-spacing: 0.02em;
      line-height: 1;
      text-align: center;
      text-transform: uppercase;
      white-space: nowrap;
      text-overflow: ellipsis;
      opacity: 0.38;
    }

    .timeline-info[data-active="true"] {
      opacity: 0.92;
    }

    @keyframes currentMarkerPulse {
      0%, 100% {
        opacity: 0.82;
        filter: brightness(1);
      }
      50% {
        opacity: 1;
        filter: brightness(1.14);
      }
    }
    
    .progress-strip-fill {
      position: absolute;
      left: 0;
      top: 0;
      height: 100%;
      transition: width 1s linear, transform 1s linear;
    }
    
    .progress-strip-fill.day-fill {
      background: rgba(96, 128, 178, 0.42);
      width: 100%;
      transform: scaleX(0);
      transform-origin: left center;
    }
    
    .progress-strip-fill.week-fill {
      background: var(--week-strip-color);
    }

    .timeline-duration-layer,
    .timeline-count-layer {
      position: absolute;
      inset: 0;
      pointer-events: none;
    }

    .timeline-duration-layer {
      z-index: 1;
    }

    .timeline-count-layer {
      z-index: 2;
    }

    .timeline-duration-segment {
      position: absolute;
      top: 0;
      bottom: 0;
      pointer-events: auto;
      background:
        linear-gradient(90deg, rgba(255,255,255,0.055), transparent 44%),
        color-mix(in srgb, var(--segment-color, #ff8c42) 42%, var(--app-bg, #000000));
      border-left: 1px solid rgba(255,255,255,0.12);
      cursor: help;
      opacity: 0.46;
    }

    .timeline-duration-segment:hover,
    .timeline-duration-segment:focus-visible {
      opacity: 0.72;
      outline: 1px solid color-mix(in srgb, var(--segment-color, #ff8c42) 65%, #ffffff);
      outline-offset: -1px;
    }

    .timeline-count-marker {
      position: absolute;
      top: 0;
      bottom: 0;
      width: 2px;
      min-width: 2px;
      pointer-events: auto;
      background: color-mix(in srgb, var(--marker-color, #ffffff) 56%, var(--app-bg, #000000));
      cursor: help;
      opacity: 0.58;
      transform: translateX(-1px);
    }

    .timeline-count-marker:hover,
    .timeline-count-marker:focus-visible {
      opacity: 0.92;
      outline: 1px solid color-mix(in srgb, var(--marker-color, #ffffff) 65%, #ffffff);
      outline-offset: 2px;
    }

    .timeline-divider-layer {
      position: absolute;
      inset: 0;
      z-index: 3;
      pointer-events: none;
    }

    .timeline-divider {
      position: absolute;
      top: 0;
      bottom: 0;
      width: 1px;
      transform: translateX(-0.5px);
      background: rgba(255,255,255,0.32);
      opacity: 0.72;
    }

    .timeline-divider.major {
      width: 2px;
      transform: translateX(-1px);
      background: rgba(255,255,255,0.44);
      opacity: 0.78;
    }

    .timeline-scrub-marker {
      position: absolute;
      top: -2px;
      bottom: -2px;
      width: 2px;
      z-index: 5;
      pointer-events: none;
      background: rgba(255,255,255,0.92);
      box-shadow: 0 0 10px rgba(255,255,255,0.34);
      transform: translateX(-1px);
    }

    /* Sunrise/sunset markers */
    .sun-marker {
      position: absolute;
      top: 0;
      width: 2px;
      height: 100%;
      background: rgba(255,255,255,0.5);
      z-index: 2;
    }
    .sun-marker::after {
      content: attr(data-label);
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      font-size: 7px;
      letter-spacing: 0.04em;
      color: rgba(255,255,255,0.6);
      white-space: nowrap;
    }
    .sun-marker.sunrise::after {
      left: 4px;
    }
    .sun-marker.sunset::after {
      right: 4px;
    }
    
    /* Controls group with consistent gaps */
    .controls-group {
      display: flex;
      flex-direction: column;
      gap: 1px;
    }

    /* LED Pulse cells */
    .btn-habit[data-type="led_pulse"] {
      transition: background 0.08s ease-out;
    }
    .btn-habit[data-type="led_pulse"].led-on {
      background: var(--btn-color, #ff8c42) !important;
    }
    .btn-habit[data-type="led_pulse"].led-off {
      background: var(--app-bg, #000) !important;
    }

    /* ===== PINS ===== */
    .pins {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      width: min(100%, var(--field-max-width));
      margin: 0 auto;
      gap: 0;
      background: var(--app-bg, #000);
    }
    .pin {
      border: none;
      background: var(--app-bg, #000);
      color: var(--app-text, rgba(255,255,255,0.5));
      opacity: 0.5;
      padding: 8px 6px;
      cursor: pointer;
      font-size: 8px;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      transition: all 100ms ease-out;
      -webkit-tap-highlight-color: transparent;
      min-height: 68px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .pin {
      background: color-mix(in srgb, var(--pin-fill, #ffffff) 30%, var(--app-bg, #000));
      color: color-mix(in srgb, var(--pin-fill, #ffffff) 64%, var(--app-text, #ffffff));
      opacity: 0.78;
      border-top: 2px solid color-mix(in srgb, var(--pin-fill, #ffffff) 68%, transparent);
    }
    .pin:hover {
      background: color-mix(in srgb, var(--pin-fill, #ffffff) 42%, var(--app-bg, #000));
      opacity: 0.9;
    }
    .pin.active {
      background: color-mix(in srgb, var(--pin-fill, #ff8c42) 76%, #ffffff);
      color: var(--pin-text, #000);
      opacity: 1;
      border-top-color: color-mix(in srgb, var(--pin-fill, #ff8c42) 64%, #ffffff);
    }
    .pin-sync-btn {
      border-left: 1px solid rgba(255,255,255,0.08);
      color: #35f2a3;
      opacity: 0.7;
      font-size: 7px;
      padding-left: 4px;
      padding-right: 4px;
    }
    .pin-sync-btn:hover { background: rgba(53,242,163,0.1); opacity: 1; }
    .pin-sync-btn[data-sync-state="dirty"],
    .pin-sync-btn[data-sync-state="queued"] {
      color: #ff8c42;
      opacity: 1;
    }
    .pin-sync-btn[data-sync-state="conflict"] {
      color: #ff4f6a;
      opacity: 1;
    }
    .pin-sync-btn[data-sync-state="busy"] {
      color: var(--app-text, #ffffff);
      opacity: 0.45;
    }

    /* ===== CONTROLS ===== */
    .controls {
      display: grid;
      grid-template-columns: repeat(6, 1fr);
      gap: 0px;
      background: var(--app-bg, #000000);
      }
    .controls-edit {
      display: grid;
      grid-template-columns: repeat(8, 1fr);
      gap: 0px;
      background: var(--app-bg, #000000);
      }
    .btn-control-wide {
      grid-column: span 3;
    }
    .btn-control-third {
      grid-column: span 2;
    }
    .btn-control-quarter {
      grid-column: span 2;
    }
    .btn-control-edit {
      grid-column: span 2;
    }
    
    .btn-control-mini {
      grid-column: span 1;
      }
.btn-control-pin {
      grid-column: span 1;
      background: transparent;
      color: var(--app-text, #ffffff);
      }
    .btn-control {
      border: none;
      background: transparent;
      color: var(--app-text, #ffffff);
      padding: 8px 6px;
      cursor: pointer;
      font-size: 8px;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      transition: all 100ms ease-out;
      -webkit-tap-highlight-color: transparent;
      min-height: 34px;
      display: flex;
      align-items: center;
      justify-content: center;
      white-space: nowrap;
      opacity: 0.6;
    }
    .btn-control:hover { background: rgba(255,255,255,0.06); opacity: 0.9; }
    .btn-control:active { background: rgba(255,255,255,0.12); }
    .btn-control.active { background: rgba(255,79,106,0.3); color: #ff4f6a; opacity: 1; }
    .controls .btn-control:not(#btnQuickInfo) {
      color: color-mix(in srgb, var(--app-text, #ffffff) 56%, var(--app-bg, #000000));
    }

    @media (min-width: 900px) {
      .controls,
      .controls-edit {
        width: min(100%, 860px);
        margin: 2px auto 0;
        opacity: 0.42;
        transition: opacity 120ms ease-out;
      }

      .controls:hover,
      .controls:focus-within,
      .controls-edit:hover,
      .controls-edit:focus-within {
        opacity: 0.78;
      }

      .controls .btn-control,
      .controls-edit .btn-control {
        min-height: 26px;
        font-size: 7px;
        opacity: 0.7;
      }
    }

    @media (min-width: 700px) {
      :root {
        --field-max-width: 820px;
        --field-cell-min: 160px;
      }
    }

    @media (min-width: 1100px) {
      :root {
        --field-max-width: 1080px;
        --field-cell-min: 210px;
      }

      body {
        padding-left: 22px;
        padding-right: 22px;
      }
    }

    @media (min-width: 1500px) {
      :root {
        --field-max-width: 1220px;
        --field-cell-min: 240px;
      }
    }

    @media (min-width: 900px) and (max-height: 780px) {
      :root {
        --field-cell-min: 176px;
      }
    }

    /* ===== VIEW TABS ===== */
    .view-tabs {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      width: min(100%, var(--field-max-width));
      margin: 0 auto;
      gap: 0;
      background: var(--app-bg, #000);
    }

    .view-tab {
      border: none;
      background: var(--app-bg, #000);
      color: var(--app-text, #fff);
      opacity: 0.5;
      padding: 9px 6px;
      min-height: 34px;
      cursor: pointer;
      font-size: 8px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      transition: all 100ms ease-out;
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
    }

    @media (min-width: 900px) {
      .pin {
        font-size: 10px;
      }

      .view-tab {
        min-height: 68px;
        font-size: 10px;
      }
    }

    .view-tab:hover {
      background: var(--view-tab-hover-bg);
      opacity: 0.85;
    }

    .view-tab.active {
      background: var(--view-tab-active-bg);
      color: var(--view-tab-active-text);
      opacity: 1;
    }

    .view-tab.preview-hold {
      background: rgba(157, 183, 232, 0.22);
      color: #d8e4ff;
      opacity: 1;
    }

    .view-panel[hidden] {
      display: none !important;
    }

    .view-panel {
      width: 100%;
    }

    .layout-toolbar {
      display: grid;
      width: min(100%, var(--field-max-width));
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
      gap: 8px;
      padding: 10px 0;
      border-bottom: 1px solid var(--stroke-soft, rgba(255,255,255,0.15));
      margin: 0 auto 8px;
    }

    .layout-heading {
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .layout-title {
      color: var(--app-text, #fff);
      font-size: 11px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
    }

    .layout-meta {
      margin-top: 3px;
      color: rgba(255,255,255,0.48);
      font-size: 9px;
      letter-spacing: 0.06em;
      text-transform: uppercase;
    }

    .layout-pin-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 6px;
      align-items: stretch;
      max-width: 360px;
    }

    .layout-actions {
      display: grid;
      grid-template-columns: repeat(3, minmax(62px, auto));
      gap: 1px;
    }

    .layout-toolbar-btn {
      border: 1px solid var(--stroke-soft, rgba(255,255,255,0.15));
      background: var(--app-bg, #000);
      color: var(--app-text, #fff);
      min-height: 34px;
      padding: 8px 12px;
      font-family: inherit;
      font-size: 8px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      cursor: pointer;
      opacity: 0.65;
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
      display: flex;
      align-items: center;
      justify-content: center;
      min-width: 0;
    }

    .layout-pin-name-btn {
      text-align: left;
      justify-content: flex-start;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      opacity: 0.82;
    }

    .layout-toolbar-btn:hover,
    .layout-toolbar-btn:active {
      background: rgba(255,255,255,0.08);
      opacity: 1;
    }

    .layout-pin-color {
      min-height: 34px;
      border: 1px solid var(--stroke-soft, rgba(255,255,255,0.15));
      display: grid;
      grid-template-columns: auto 34px;
      align-items: center;
      gap: 6px;
      padding-left: 8px;
      color: rgba(255,255,255,0.56);
      font-size: 8px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
    }

    .layout-pin-color input {
      width: 34px;
      height: 100%;
      padding: 0;
      border: none;
      background: transparent;
      cursor: pointer;
    }

    /* ===== HABITS GRID ===== */
    .buttons-grid,
    .layout-grid {
      display: grid;
      width: min(100%, var(--field-max-width));
      margin: 0 auto;
      grid-template-columns: repeat(var(--layout-columns, 3), minmax(0, 1fr));
      grid-auto-flow: dense;
      grid-auto-rows: minmax(var(--field-cell-min), auto);
      gap: 0;
      background: var(--app-bg, #000);
      border: none;
    }

    .btn-habit {
      border: none;
      background: var(--app-bg, #000);
      color: var(--app-text, #fff);
      padding: 8px;
      cursor: pointer;
      font-size: 13px;
      letter-spacing: 0.06em;
      text-align: center;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 4px;
      transition: all 100ms ease-out;
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
      position: relative;
      overflow: hidden;
      -webkit-user-select: none;
      user-select: none;
      min-width: 0;
      min-height: var(--field-cell-min);
    }

    .btn-habit[data-col-span="2"],
    .btn-habit[data-row-span="2"] {
      aspect-ratio: auto;
    }

    .layout-cell {
      min-width: 0;
      min-height: var(--field-cell-min);
      padding: 8px;
      border: 1px solid var(--stroke-soft, rgba(255,255,255,0.15));
      background: linear-gradient(135deg, rgba(255,255,255,0.055), rgba(255,255,255,0.015));
      color: var(--app-text, #fff);
      display: grid;
      grid-template-rows: auto 1fr auto auto;
      gap: 8px;
      position: relative;
      overflow: hidden;
      cursor: pointer;
    }

    .layout-cell::before {
      content: '';
      position: absolute;
      inset: 0;
      border-top: 2px solid var(--btn-color, #35f2a3);
      opacity: 0.72;
      pointer-events: none;
    }

    .layout-cell[data-empty="true"] {
      background: rgba(255,255,255,0.015);
      border-style: dashed;
    }

    .layout-cell[data-empty="true"] .layout-cell-name {
      opacity: 0.42;
    }

    .layout-cell-meta,
    .layout-cell-type {
      position: relative;
      z-index: 1;
      color: rgba(255,255,255,0.48);
      font-size: 8px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      text-align: center;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .layout-cell-name {
      position: relative;
      z-index: 1;
      align-self: center;
      color: var(--app-text, #fff);
      font-size: 12px;
      letter-spacing: 0.04em;
      text-align: center;
      text-transform: uppercase;
      word-break: break-word;
    }

    .layout-cell-actions {
      position: relative;
      z-index: 1;
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 1px;
    }

    .layout-action {
      min-height: 28px;
      border: none;
      background: rgba(0,0,0,0.62);
      color: rgba(255,255,255,0.72);
      font-family: inherit;
      font-size: 8px;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      cursor: pointer;
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
    }

    .layout-action:hover:not(:disabled),
    .layout-action:active:not(:disabled) {
      background: #35f2a3;
      color: #000;
    }

    .layout-action:disabled {
      opacity: 0.28;
      cursor: default;
    }

    /* INACTIVE CELLS - different patterns per pin */
    .btn-habit.inactive {
      background: var(--app-bg, #000);
      cursor: default;
      opacity: 0.42;
      pointer-events: none;
    }
    
    /* PIN 01 - diagonal cross using SVG for clean intersection */
    [data-pin="0"] .btn-habit.inactive::after {
      content: '';
      position: absolute;
      inset: 0;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3E%3Cline x1='0' y1='0' x2='100%25' y2='100%25' stroke='%23505050' stroke-width='1'/%3E%3Cline x1='100%25' y1='0' x2='0' y2='100%25' stroke='%23505050' stroke-width='1'/%3E%3C/svg%3E");
      background-size: 100% 100%;
      pointer-events: none;
    }


    /* PIN 02 - grid using SVG */
    [data-pin="1"] .btn-habit.inactive::after {
      content: '';
      position: absolute;
      inset: 0;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3E%3Cline x1='50%25' y1='0' x2='50%25' y2='100%25' stroke='%23505050' stroke-width='1'/%3E%3Cline x1='0' y1='50%25' x2='100%25' y2='50%25' stroke='%23505050' stroke-width='1'/%3E%3C/svg%3E");
      background-size: 100% 100%;
      pointer-events: none;
    }

    /* PIN 03 - diagonal + grid */
    [data-pin="2"] .btn-habit.inactive::after {
      content: '';
      position: absolute;
      inset: 0;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3E%3Cline x1='0' y1='0' x2='100%25' y2='100%25' stroke='%23505050' stroke-width='1'/%3E%3Cline x1='50%25' y1='0' x2='50%25' y2='100%25' stroke='%23505050' stroke-width='1'/%3E%3Cline x1='0' y1='50%25' x2='100%25' y2='50%25' stroke='%23505050' stroke-width='1'/%3E%3C/svg%3E");
      background-size: 100% 100%;
      pointer-events: none;
    }



    /* Cell content structure */
    .btn-status {
      display: block;
      font-size: 10px;
      line-height: 1.2;
      margin-bottom: 3px;
      text-transform: lowercase;
      letter-spacing: 0.16em;
      opacity: 0.9;
    }
    .btn-status-countdown {
      text-transform: lowercase;
      opacity: 0.7;
    }
    .btn-status-timer {
      text-transform: lowercase;
      opacity: 0.7;
    }


    .btn-label { 
      font-size: 11px; 
      font-weight: 400; 
      opacity: 0.7;
      order: 2;
    }
    .btn-value { 
      font-family: "Roboto Condensed", -apple-system, BlinkMacSystemFont, sans-serif;
      font-size: clamp(22px, 9vw, 36px);
      font-weight: 700;
      font-variant-numeric: tabular-nums;
      line-height: 1;
      order: 3;
      letter-spacing: -0.02em;
      word-spacing: 0;
      font-feature-settings: "tnum" 1;
    }

    /* Countdown digits: stroke with black fill */
    .btn-habit[data-type="countdown"] .btn-value {
      color: #000000;
      -webkit-text-stroke: 1px var(--btn-color, #ffffff);
      text-stroke: 1px var(--btn-color, #ffffff);
    }

    .btn-habit[data-type="countdown"] .btn-value .btn-value-suffix {
      color: var(--btn-color, #ffffff);
      -webkit-text-stroke: 0;
      text-stroke: 0;
    }

    /* Small suffix letters (s, m) - 5x smaller */
    .btn-value-suffix {
      font-size: 0.5em;
      opacity: 0.6;
      margin-left: 0.1em;
    }

    .btn-breakdown {
      font-size: 9px;
      opacity: 0.5;
      letter-spacing: 0.06em;
      order: 4;
      min-height: 14px;
    }
    
    /* Responsive font tuning: phones a bit smaller, desktops a bit larger */
    @media (max-width: 600px) {
      .btn-label { font-size: 9px; }
      .btn-value { font-size: clamp(18px, 8vw, 30px); }
      .btn-breakdown { font-size: 9px; }
    }
    @media (min-width: 1200px) {
      .btn-label { font-size: 13px; }
      .btn-value { font-size: clamp(26px, 10vw, 44px); }
      .btn-breakdown { font-size: 11px; }
    }


    /* Running state with animated border */
    
    /* Running states base */
    .btn-habit.running {
      position: relative;
    }

    .btn-habit.prev-week-preview {
      background:
        linear-gradient(135deg, color-mix(in srgb, var(--btn-color, #ffffff) 12%, transparent), transparent 42%),
        var(--btn-bg, #000);
      outline: 1px solid color-mix(in srgb, var(--btn-color, #ffffff) 32%, transparent);
      opacity: 0.82;
    }

    /* Duration types - colored border and background pulse */
    .btn-habit[data-type="duration_sec"].running,
    .btn-habit[data-type="duration_min"].running,
    .btn-habit[data-type="sleep"].running,
    .btn-habit[data-type="duration_sec_count"].running {
      border: 3px solid rgba(255, 255, 255, 0.1);
      background: color-mix(in srgb, var(--btn-color, #35f2a3) 15%, transparent);
      box-shadow: inset 0 0 0 3px var(--btn-color, #35f2a3);
      animation: borderPulse 2s ease-in-out infinite;
    }

    @keyframes borderPulse {
      0%, 100% {
        box-shadow: inset 0 0 0 3px var(--btn-color, #35f2a3);
      }
      50% {
        box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--btn-color, #35f2a3) 50%, transparent);
      }
    }

    /* TIMER - top edge progress bar, black background, pulsing value */
    .btn-habit[data-type="timer"].running {
      border: 2px solid rgba(255, 255, 255, 0.35);
      background: #000;
    }

    .btn-habit[data-type="timer"].running::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 70%;
      height: 2px;
      background: var(--btn-color, #35f2a3);
      pointer-events: none;
      z-index: 2;
      animation: timerScan 60s linear infinite;
    }

    @keyframes timerScan {
      0% {
        left: -3px;
        right: 60%;
      }
      50% {
        left: 60%;
        right: -3px;
      }
      100% {
        left: -3px;
        right: 60%;
      }
    }

    /* COUNTDOWN - perimeter snake over one-minute cycle */
    .btn-habit[data-type="countdown"].running {
      border: none;
      background: #000;
    }

    .btn-habit[data-type="countdown"].running::after {
      content: '';
      position: absolute;
      left: 50%;
      top: 50%;
      width: 160%;
      height: 2px;
      background: var(--btn-color, #ffffff);
      pointer-events: none;
      z-index: 0;
      transform-origin: center center;
      transform: translate(-50%, -50%) rotate(var(--progress-angle, 0deg));
      opacity: 1;
      animation: none;
    }

    @keyframes countdownSnake {
      0% {
        transform: translateX(-50%) rotate(0deg);
      }
      100% {
        transform: translateX(-50%) rotate(-360deg);
      }
    }

/* Common z-index for content on top of effects */
    .btn-habit.running > * {
      position: relative;
      z-index: 1;
    }

    /* Value color for active cells */
    .btn-habit[data-type="duration_sec"].running .btn-value,
    .btn-habit[data-type="duration_min"].running .btn-value,
    .btn-habit[data-type="sleep"].running .btn-value,
    .btn-habit[data-type="duration_sec_count"].running .btn-value,
    .btn-habit[data-type="timer"].running .btn-value {
      color: var(--btn-color, #35f2a3);
    }

    /* Timer text pulse */
    .btn-habit[data-type="timer"].running .btn-value {
      animation: timerTextPulse 16s ease-in-out infinite;
    }

    @keyframes timerTextPulse {
      0%, 100% {
        transform: scale(1);
        filter: brightness(1);
      }
      50% {
        transform: scale(1.08);
        filter: brightness(1.9);
      }
    }

    /* Countdown hourly flash */
    .btn-habit[data-type="countdown"].hour-ping {
      animation: countdownHourPing 0.8s ease-out;
    }

    @keyframes countdownHourPing {
      0% {
        box-shadow: 0 0 0 rgba(255,255,255,0);
      }
      40% {
        box-shadow: 0 0 40px rgba(255,255,255,0.9);
      }
      100% {
        box-shadow: 0 0 0 rgba(255,255,255,0);
      }
    }

    /* Countdown expired blinking value */
    .btn-habit[data-type="countdown"].pulsing .btn-value {
      animation: countdownExpired 1s steps(2, end) infinite;
    }

    @keyframes countdownExpired {
      0%, 100% { opacity: 1; }
      50%      { opacity: 0.4; }
    }

    /* Stronger tap feedback when value changes */
    .btn-habit.animating {
      animation: tapPress 1200ms cubic-bezier(0.22, 0.61, 0.36, 1);
    }

    /* Countdown click feedback: text color flashes to accent, no background glow */
    .btn-habit[data-type="countdown"] .btn-label,
    .btn-habit[data-type="countdown"] .btn-status,
    .btn-habit[data-type="countdown"] .btn-value,
    .btn-habit[data-type="countdown"] .btn-breakdown {
      transition: color 5000ms ease-out;
    }

    .btn-habit[data-type="countdown"].animating .btn-label,
    .btn-habit[data-type="countdown"].animating .btn-status,
    .btn-habit[data-type="countdown"].animating .btn-value,
    .btn-habit[data-type="countdown"].animating .btn-breakdown {
      color: var(--btn-color, #ffffff);
      transition: none;
    }



    @keyframes tapPress {
      0% {
        transform: scale(1);
        filter: brightness(1);
      }
      30% {
        transform: scale(0.96);
        filter: brightness(1.6);
      }
      100% {
        transform: scale(1);
        filter: brightness(1.05);
      }
    }
/* Paused state */
    .btn-habit.paused {
      border: 2px solid var(--stroke-soft, rgba(255,255,255,0.15));
    }
    .btn-habit.paused .btn-value,
    .btn-habit.paused .btn-label,
    .btn-habit.paused .btn-status {
      opacity: 0.35;
    }

    /* Pulsing animation for expired countdown */
    .btn-habit.pulsing {
      animation: fastPulse 0.5s ease-in-out infinite;
    }
    @keyframes fastPulse {
      0%, 100% { 
        border-color: rgba(255,79,106,0.8);
        background: rgba(255,79,106,0.15);
      }
      50% { 
        border-color: rgba(255,79,106,0.3);
        background: rgba(255,79,106,0.05);
      }
    }

    /* Flash animation on click - bright and slow fade */
    .btn-habit::before {
      content: '';
      position: absolute;
      inset: 0;
      background: var(--btn-color, transparent);
      opacity: 0;
      pointer-events: none;
      z-index: 0;
    }
    .btn-habit.animating::before {
      animation: flash 1500ms ease-out forwards;
    }
    @keyframes flash {
      0% { opacity: 1; }
      10% { opacity: 0.95; }
      30% { opacity: 0.7; }
      100% { opacity: 0; }
    }
    .btn-habit > * { position: relative; z-index: 2; }

    /* ===== STATS ===== */
    .stats {
      padding: 0;
      overflow-x: auto;
    }
    .history-toolbar {
      display: grid;
      grid-template-columns: 1fr auto;
      align-items: center;
      min-height: 34px;
      padding: 0 8px;
      border-bottom: 1px solid var(--stroke-strong, rgba(80,80,80,1));
      color: var(--app-text, #fff);
    }
    .history-correct-btn {
      margin-top: 5px;
      padding: 5px 9px;
      border: 1px solid rgba(255,255,255,0.22);
      background: rgba(255,255,255,0.04);
      color: var(--app-text, #fff);
      font-family: inherit;
      font-size: 8px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      cursor: pointer;
    }
    .history-correct-btn:hover,
    .history-correct-btn:focus-visible {
      background: rgba(255,255,255,0.12);
      outline: none;
    }
    .history-nav {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 6px;
      min-width: 0;
    }
    .history-nav-btn {
      min-height: 24px;
      padding: 4px 8px;
      border: 1px solid rgba(255,255,255,0.18);
      background: rgba(255,255,255,0.03);
      color: var(--app-text, #fff);
      font-family: inherit;
      font-size: 8px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      cursor: pointer;
      opacity: 0.68;
    }
    .history-nav-btn:hover,
    .history-nav-btn:focus-visible {
      opacity: 1;
      background: rgba(255,255,255,0.1);
      outline: none;
    }
    .history-nav-btn:disabled {
      opacity: 0.24;
      cursor: default;
    }
    .history-timeline-stack {
      width: min(100%, var(--field-max-width));
      margin: 0 auto 8px;
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
    .history-timeline-meta {
      display: flex;
      justify-content: space-between;
      align-items: center;
      min-height: 16px;
      color: var(--app-text, #fff);
      opacity: 0.62;
      font-family: "Roboto Condensed", -apple-system, sans-serif;
      font-size: 10px;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      font-variant-numeric: tabular-nums;
    }
    .history-progress-strip {
      height: 18px;
    }
    .history-title,
    .history-meta {
      font-size: 8px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      opacity: 0.55;
    }
    .stats-table {
      width: 100%;
      border-collapse: collapse;
      color: rgba(255,255,255,0.8);
    }
    
    .stats-table th, .stats-table td {
      padding: 10px 8px;
      text-align: center;
      border-right: 1px solid var(--stroke-strong, rgba(80,80,80,1));
      border-bottom: 1px solid var(--stroke-strong, rgba(80,80,80,1));
      background: transparent;
    }
    
    .stats-table th:last-child,
    .stats-table td:last-child {
      border-right: none;
    }
    
    .stats-table tbody tr:last-child td {
      border-bottom: none;
    }
    
    .stats-table th {
      font-size: 8px;
      font-weight: 400;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: var(--app-text, rgba(255,255,255,0.5));
      opacity: 0.5;
    }
    
    .stats-table td {
      font-family: "Roboto Condensed", -apple-system, sans-serif;
      font-size: 13px;
      font-weight: 700;
      font-variant-numeric: tabular-nums;
      color: var(--app-text, rgba(255,255,255,0.8));
      opacity: 0.8;
    }
    
    .stats-table td:first-child, 
    .stats-table th:first-child {
      text-align: left;
      font-family: system-ui, -apple-system, sans-serif;
      font-size: 8px;
      font-weight: 400;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: var(--app-text, rgba(255,255,255,0.5));
      opacity: 0.5;
      cursor: pointer;
      transition: color 100ms ease-out;
    }

    /* Hover on week label only */
    .stats-table tbody td:first-child:hover {
      color: #ff8c42;
    }

    /* Hover effects - subtle */
    .stats-table tbody tr.row-highlight {
      background: rgba(255,140,66,0.03);
    }

    .stats-table tbody tr.history-week-selected {
      background: rgba(157,183,232,0.08);
    }

    .stats-table tbody tr.history-week-selected td:first-child {
      color: #9db7e8;
      opacity: 0.9;
    }

    .stats-table th.col-highlight,
    .stats-table td.col-highlight {
      background: rgba(255,140,66,0.05) !important;
      color: #ff8c42 !important;
    }

    .stats-table th.cell-highlight,
    .stats-table td.cell-highlight {
      background: rgba(255,140,66,0.25) !important;
      color: #ff8c42 !important;
      font-weight: 500;
    }

    @media (orientation: landscape) and (max-height: 560px) and (max-width: 980px) {
      body {
        padding: calc(6px + env(safe-area-inset-top)) 10px calc(6px + env(safe-area-inset-bottom));
      }

      body[data-view="history"] .container {
        max-width: none;
        height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 12px);
      }

      body[data-view="history"] .header > .progress-meta,
      body[data-view="history"] .header > .progress-strip,
      body[data-view="history"] .controls,
      body[data-view="history"] .controls-edit,
      body[data-view="history"] .pins {
        display: none;
      }

      body[data-view="history"] .view-tabs {
        width: 100%;
      }

      body[data-view="history"] .view-tab {
        min-height: 30px;
        padding: 5px 6px;
        font-size: 8px;
      }

      body[data-view="history"] #historyView {
        flex: 1;
        min-height: 0;
        display: grid;
        grid-template-rows: auto minmax(0, 1fr);
        gap: 6px;
      }

      body[data-view="history"] .history-toolbar {
        grid-template-columns: auto minmax(0, 1fr);
        min-height: 28px;
        padding: 0 4px;
      }

      body[data-view="history"] .history-correct-btn {
        margin-top: 2px;
        min-height: 22px;
        padding: 3px 8px;
      }

      body[data-view="history"] .history-nav {
        gap: 4px;
      }

      body[data-view="history"] .history-nav-btn {
        min-height: 24px;
        padding: 3px 8px;
      }

      body[data-view="history"] .history-meta {
        font-size: 9px;
        opacity: 0.82;
      }

      body[data-view="history"] .history-timeline-stack {
        width: 100%;
        min-height: 0;
        margin: 0;
        gap: 6px;
        display: grid;
        grid-template-rows: auto minmax(78px, 1.35fr) auto minmax(54px, 0.95fr) 24px;
      }

      body[data-view="history"] .history-timeline-meta {
        min-height: 14px;
        padding: 0 2px;
      }

      body[data-view="history"] .history-progress-strip {
        height: 100%;
        min-height: 54px;
      }

      body[data-view="history"] #historyDayStrip {
        min-height: 82px;
      }

      body[data-view="history"] #historyWeekStrip {
        min-height: 56px;
      }

      body[data-view="history"] .timeline-info {
        min-height: 24px;
        font-size: 13px;
      }

      body[data-view="history"] .timeline-duration-segment {
        opacity: 0.58;
      }

      body[data-view="history"] .timeline-count-marker {
        width: 4px;
        min-width: 4px;
        transform: translateX(-2px);
      }

      body[data-view="history"] .stats {
        display: none;
      }
    }

    /* ===== MODALS ===== */
    .modal {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.8);
      z-index: 100;
      align-items: center;
      justify-content: center;
      padding: 16px;
    }
    .modal.visible { display: flex; }

    .modal-content {
      background: var(--app-bg, #000);
      border: none;
      max-height: 80vh;
      overflow-y: auto;
      max-width: 500px;
      width: 100%;
      display: flex;
      flex-direction: column;
      gap: 16px;
      padding: 20px;
    }

    @media (max-width: 640px) {
      .modal {
        align-items: flex-start;
        padding: calc(12px + env(safe-area-inset-top)) 12px calc(96px + env(safe-area-inset-bottom));
        overflow-y: auto;
      }

      .modal-content,
      .cell-edit-content,
      .info-modal-content,
      .correction-modal-content {
        max-height: none;
        padding-bottom: calc(128px + env(safe-area-inset-bottom));
      }
    }

    .modal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      border: 0px solid rgba(255,255,255,0.3);
      padding: 16px 20px 12px;
    }
    .modal-title {
      font-size: 10px;
      letter-spacing: 0.06em;
      color: rgba(255,255,255,0.5);
      margin-bottom: 8px;
      text-transform: uppercase;
    }
    .modal-header-right {
      display: flex;
      gap: 8px;
      align-items: center;
    }
    .modal-pin-btn {
      border: 1px solid rgba(255,255,255,0.4);
      background: #000;
      color: rgba(255,255,255,0.8);
      padding: 6px 10px;
      font-size: 10px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      cursor: pointer;
    }
    .modal-pin-btn:hover {
      background: #fff;
      color: #000;
    }
    .modal-help-btn {
      border: 1px solid rgba(255,255,255,0.4);
      background: #000;
      color: rgba(255,255,255,0.7);
      padding: 5px 8px;
      font-size: 10px;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      cursor: pointer;
    }
    .modal-help-btn:hover {
      background: #fff;
      color: #000;
    }

    
    .modal-help-panel,
    .cell-help-panel {
      display: none;
      margin-top: 12px;
      padding: 10px 12px;
      border: 1px solid rgba(255,255,255,0.3);
      background: rgba(0,0,0,0.9);
      font-size: 9px;
      line-height: 1.6;
      color: rgba(255,255,255,0.75);
    }
    .modal-help-panel.visible,
    .cell-help-panel.visible {
      display: block;
    }
.modal-buttons {
      display: flex;
      gap: 1px;
      border: 1px solid rgba(255,255,255,0.3);
    }
    .modal-btn {
      flex: 1;
      border: none;
      background: #000;
      color: rgba(255,255,255,0.7);
      padding: 12px 8px;
      font-size: 10px;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      cursor: pointer;
      transition: all 100ms ease-out;
      -webkit-tap-highlight-color: transparent;
    }
    .modal-btn:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.9); }
    .modal-btn.primary { background: #35f2a3; color: #000; }
    .modal-btn.primary:hover { background: #4df7b5; }
    .modal-btn.danger { color: rgba(255,79,106,0.78); }
    .modal-btn.danger.confirming { background: rgba(255,79,106,0.28); color: #ff4f6a; }
    .modal-btn:disabled {
      cursor: not-allowed;
      opacity: 0.25;
    }

    .account-modal-content {
      max-width: 520px;
      gap: 12px;
    }

    .account-card,
    .account-section {
      display: flex;
      flex-direction: column;
      gap: 8px;
      padding: 12px;
      background: rgba(255,255,255,0.04);
    }

    .account-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      min-height: 24px;
    }

    .account-label,
    .account-value,
    .account-status {
      font-size: 10px;
      letter-spacing: 0.06em;
      text-transform: uppercase;
    }

    .account-label {
      color: rgba(255,255,255,0.42);
    }

    .account-value {
      color: rgba(255,255,255,0.78);
      text-align: right;
      word-break: break-word;
    }

    .account-status {
      padding: 10px 8px;
      text-align: center;
      background: rgba(255,255,255,0.05);
      color: rgba(255,255,255,0.72);
    }

    .account-status[data-status="ok"] {
      background: rgba(53,242,163,0.16);
      color: #35f2a3;
    }

    .account-status[data-status="warn"] {
      background: rgba(255,171,64,0.14);
      color: #ffab40;
    }

    .account-status[data-status="error"] {
      background: rgba(255,79,106,0.16);
      color: #ff4f6a;
    }

    .account-action-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 1px;
      border: 1px solid rgba(255,255,255,0.18);
    }

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

    .account-auth-grid[data-signup-unlocked="false"] {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .account-email-label {
      cursor: default;
      user-select: none;
      -webkit-user-select: none;
      touch-action: manipulation;
    }

    .account-email-label[data-unlocked="true"] {
      color: #35f2a3;
    }

    .account-full-btn {
      width: 100%;
      border: 1px solid rgba(255,255,255,0.18);
    }

    .account-config-toggle {
      width: 100%;
      min-height: 32px;
      border: 1px solid rgba(255,255,255,0.14);
      background: rgba(255,255,255,0.03);
      color: rgba(255,255,255,0.48);
      font-size: 9px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      cursor: pointer;
      -webkit-tap-highlight-color: transparent;
    }

    .account-config-toggle:hover {
      background: rgba(255,255,255,0.06);
      color: rgba(255,255,255,0.72);
    }

    .account-config-body {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .account-config-body[hidden] {
      display: none;
    }

    /* Edit items grid */
    .edit-items-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 1px;
      border: 1px solid rgba(255,255,255,0.3);
      background: rgba(255,255,255,0.3);
    }
    .edit-item {
      background: #000;
      border: none;
      padding: 16px 8px;
      cursor: pointer;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 8px;
      min-height: 80px;
      -webkit-tap-highlight-color: transparent;
    }
    .edit-item:hover { background: rgba(255,255,255,0.04); }
    .edit-item-label {
      font-size: 9px;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: rgba(255,255,255,0.4);
    }
    .edit-item-name {
      font-size: 12px;
      color: #fff;
      text-align: center;
      word-break: break-word;
    }

    /* Cell edit modal */
    .cell-edit-content {
      background: #000;
      border: 1px solid rgba(255,255,255,0.3);
      padding: 20px;
      max-width: 520px;
      width: 100%;
      max-height: 88vh;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 12px;
      position: relative;
    }
    
    .cell-edit-help-btn {
      position: absolute;
      top: 14px;
      right: 16px;
      border: 1px solid rgba(255,255,255,0.4);
      background: #000;
      color: rgba(255,255,255,0.7);
      padding: 4px 7px;
      font-size: 10px;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      cursor: pointer;
    }
    .cell-edit-help-btn:hover {
      background: #fff;
      color: #000;
    }

    .cell-edit-section {
      margin-top: 12px;
      padding-top: 12px;
      border-top: 1px solid rgba(255,255,255,0.1);
    }

    .cell-edit-grid-2 {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      gap: 10px 12px;
    }

    .cell-edit-grid-3 {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px 12px;
    }

    .flag-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 1px;
    }

    .flag-toggle {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      min-height: 34px;
      padding: 8px 6px;
      background: rgba(255,255,255,0.04);
      color: var(--app-text, #fff);
      font-size: 9px;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      opacity: 0.75;
      cursor: pointer;
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
    }

    .flag-toggle input {
      accent-color: #35f2a3;
    }

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

    .dashboard-toggle {
      min-height: 42px;
    }

    .layout-size-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 1px;
    }

    .layout-size-btn {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 7px;
      min-height: 62px;
    }

    .layout-size-preview {
      width: 24px;
      height: 24px;
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      grid-template-rows: repeat(2, 1fr);
      gap: 1px;
      padding: 1px;
      border: 1px solid currentColor;
      opacity: 0.75;
    }

    .layout-size-preview span {
      background: currentColor;
      grid-column: 1;
      grid-row: 1;
    }

    .layout-size-2x1 span {
      grid-column: 1 / span 2;
    }

    .layout-size-1x2 span {
      grid-row: 1 / span 2;
    }

    .layout-size-2x2 span {
      grid-column: 1 / span 2;
      grid-row: 1 / span 2;
    }

    @media (max-width: 480px) {
      .layout-size-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
    }

    .cell-edit-field {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .cell-edit-field-full {
      grid-column: 1 / -1;
    }

    .cell-edit-inline {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .sound-test-btn {
      padding: 8px 10px;
      border-radius: 4px;
      border: 1px solid rgba(255,255,255,0.4);
      background: #050607;
      color: #fff;
      font-size: 11px;
      font-family: inherit;
      cursor: pointer;
      flex-shrink: 0;
      transition: background 120ms, transform 120ms;
    }

    .sound-test-btn:active {
      transform: scale(0.96);
    }

    .sound-test-btn:hover {
      background: rgba(255,255,255,0.12);
    }

    @media (max-width: 480px) {
.cell-edit-content {
        max-width: 100%;
        padding: 16px;
      }
    }

    .cell-edit-label {
      font-size: 10px;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: rgba(255,255,255,0.5);
      text-align: center;
    }
    .cell-edit-input {
      background: #050607;
      border: 1px solid rgba(255,255,255,0.2);
      color: #fff;
      padding: 12px;
      font-size: 14px;
      font-family: inherit;
      text-align: center;
    }
    .cell-edit-input:focus {
      outline: none;
      border-color: #35f2a3;
    }

    .correction-modal-content {
      max-width: 620px;
      max-height: 88vh;
      overflow-y: auto;
    }

    .correction-list {
      display: flex;
      flex-direction: column;
      gap: 8px;
      min-height: 42px;
    }

    .correction-empty {
      padding: 14px 8px;
      border: 1px solid rgba(255,255,255,0.12);
      color: rgba(255,255,255,0.48);
      font-size: 10px;
      letter-spacing: 0.06em;
      text-align: center;
      text-transform: uppercase;
    }

    .correction-session {
      display: grid;
      grid-template-columns: 1fr 1fr auto;
      gap: 8px;
      align-items: end;
      padding: 10px;
      background: rgba(255,255,255,0.04);
      border: 1px solid rgba(255,255,255,0.12);
    }

    .correction-session-meta {
      grid-column: 1 / -1;
      color: rgba(255,255,255,0.68);
      font-size: 10px;
      letter-spacing: 0.04em;
      text-align: center;
      text-transform: uppercase;
      font-variant-numeric: tabular-nums;
    }

    .correction-session-actions {
      display: flex;
      gap: 4px;
    }

    .correction-action-btn,
    .correction-add-btn {
      min-height: 42px;
    }

    .correction-action-btn.danger {
      color: #ff6b6b;
    }

    @media (max-width: 560px) {
      .correction-session {
        grid-template-columns: 1fr;
      }

      .correction-session-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
      }
    }

    .type-selector {
      display: flex;
      gap: 1px;
    }
    .type-btn {
      flex: 1;
      padding: 10px 4px;
      background: var(--panel-bg, #050607);
      border: none;
      color: var(--panel-text-muted, rgba(255,255,255,0.6));
      font-size: 9px;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      cursor: pointer;
      transition: all 100ms;
    }
    .type-btn:hover { background: rgba(255,255,255,0.08); }
    .type-btn.active { background: #35f2a3; color: #000; }

    .color-picker-wrap {
      margin-top: 8px;
      padding-top: 12px;
      text-align: center;
    }
    .color-picker-label {
      font-size: 10px;
      color: rgba(255,255,255,0.5);
      text-transform: uppercase;
      letter-spacing: 0.04em;
      margin-bottom: 8px;
    }
    .color-picker {
      width: 100%;
      height: 40px;
      border: none;
      background: #050607;
      cursor: pointer;
      padding: 2px;
    }
    .color-picker::-webkit-color-swatch-wrapper { padding: 0; }
    .color-picker::-webkit-color-swatch { border: none; }

    /* Info modal */
    .info-modal-content {
      background: var(--app-bg, #000);
      border: none;
      padding: 24px;
      max-width: 450px;
      width: 100%;
      max-height: 85vh;
      overflow-y: auto;
    }
    .info-header {
      text-align: center;
      margin-bottom: 20px;
      padding-bottom: 16px;
    }
    .info-logo {
      font-size: 24px;
      font-weight: 700;
      letter-spacing: 0.08em;
      line-height: 1.2;
      margin-bottom: 8px;
    }
    .info-version {
      font-size: 11px;
      letter-spacing: 0.08em;
      color: rgba(255,255,255,0.4);
      margin-bottom: 4px;
    }
    .info-author {
      font-size: 10px;
      letter-spacing: 0.06em;
      color: rgba(255,255,255,0.3);
    }
    .info-author a {
      color: rgba(255,255,255,0.5);
      text-decoration: none;
    }
    .info-author a:hover { color: #ff8c42; }

    .info-section {
      margin-bottom: 16px;
    }
    .info-section-title {
      font-size: 10px;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: #ff8c42;
      margin-bottom: 6px;
    }
    .info-text {
      font-size: 12px;
      line-height: 1.6;
      color: rgba(255,255,255,0.75);
    }

    .info-footer {
      margin-top: 20px;
      padding-top: 16px;
      border-top: 1px solid rgba(255,255,255,0.1);
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    .info-buttons {
      display: flex;
      gap: 8px;
    }
    .info-button {
      flex: 1;
      border: 1px solid rgba(255,255,255,0.3);
      background: #000;
      color: rgba(255,255,255,0.7);
      padding: 10px 12px;
      font-size: 9px;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      cursor: pointer;
      transition: all 100ms ease-out;
      text-decoration: none;
      text-align: center;
    }
    .info-button:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.9); }

    /* Pulse animation for ? button */
    @keyframes btnPulse {
      0%, 100% { background: rgba(255,140,66,0.3); }
      50% { background: rgba(255,140,66,0.6); }
    }
    #btnQuickInfo.pulse {
      animation: btnPulse 1.5s ease-in-out infinite;
      color: #ff8c42;
    }
