﻿    .mode-page {
      display: none;
      height: 100vh;
      padding: 18px 16px calc(18px + var(--safe-bottom));
      flex-direction: column;
    }

    .mode-page.active { display: flex; }

    .mode-header {
      display: grid;
      grid-template-columns: 44px 1fr 44px;
      align-items: center;
      gap: 10px;
    }

    .mode-header h1 {
      margin: 0;
      text-align: center;
      font-size: 20px;
      font-weight: 900;
    }

    .mode-back-button,
    .mode-calendar-button {
      width: 44px;
      height: 44px;
      border-radius: 50%;
      background: var(--panel);
      box-shadow: var(--shadow);
      font-size: 24px;
      font-weight: 900;
    }

    .calendar-glyph {
      width: 22px;
      height: 22px;
      border: 2px solid currentColor;
      border-radius: 6px;
      display: inline-block;
      position: relative;
    }

    .calendar-glyph::before {
      content: "";
      position: absolute;
      left: -2px;
      right: -2px;
      top: 4px;
      height: 2px;
      background: currentColor;
    }

    .calendar-glyph::after {
      content: "";
      position: absolute;
      left: 5px;
      top: 10px;
      width: 4px;
      height: 4px;
      border-radius: 50%;
      background: currentColor;
      box-shadow: 7px 0 0 currentColor, 0 6px 0 currentColor, 7px 6px 0 currentColor;
    }

    .mode-list {
      margin-top: 16px;
      flex: 1;
      min-height: 0;
      overflow-y: auto;
      padding-bottom: 12px;
    }

    .mode-card {
      position: relative;
      margin-bottom: 10px;
      border-radius: var(--radius);
      background: var(--panel);
      box-shadow: var(--shadow);
      padding: 16px;
    }

    .mode-card h2 {
      margin: 0;
      font-size: 18px;
      font-weight: 900;
    }

    .mode-card p {
      margin: 6px 0 12px;
      color: var(--muted);
      font-size: 12px;
      font-weight: 800;
    }

    .mode-card-actions {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }

    .mode-card-actions button,
    .mode-add-button {
      min-height: 48px;
      border-radius: 16px;
      background: #f1f5ee;
      font-weight: 900;
    }

    .mode-card-actions button:first-child {
      grid-column: 1 / -1;
      background: var(--green);
      color: white;
    }

    .mode-active-badge {
      position: absolute;
      top: 14px;
      right: 14px;
      min-height: 26px;
      padding: 0 10px;
      border-radius: 999px;
      display: inline-grid;
      place-items: center;
      background: var(--green);
      color: white;
      font-size: 12px;
      font-weight: 900;
    }

    .mode-add-button {
      width: 100%;
      margin-top: 12px;
      background: var(--green);
      color: white;
      box-shadow: var(--shadow);
      flex-shrink: 0;
    }

    .mode-edit-panel {
      margin-top: 14px;
    }

    .mode-routine-list .task-row {
      grid-template-columns: 2fr 7fr 1fr;
      cursor: grab;
      touch-action: none;
      user-select: none;
      -webkit-user-select: none;
      transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease;
    }

    .mode-routine-list .task-row.dragging {
      opacity: .58;
      transform: scale(.99);
      box-shadow: 0 14px 28px rgba(35, 60, 45, .18);
    }

    .mode-title-cell {
      justify-content: space-between;
      gap: 10px;
    }

    .mode-title-text {
      min-width: 0;
    }

    .mode-remove-button,
    .mode-select-button {
      width: 28px;
      height: 28px;
      border-radius: 50%;
      display: grid;
      place-items: center;
      background: #f1f5ee;
      color: var(--muted);
      font-weight: 900;
    }

    .mode-select-button.selected {
      background: var(--green);
      color: white;
    }

    .mode-add-menu {
      left: 16px;
      right: 16px;
      bottom: calc(84px + var(--safe-bottom));
      width: auto;
    }

    .show-order .mode-add-menu.open {
      display: block;
    }

    .mode-name-input {
      width: 100%;
      min-height: 50px;
      margin-top: 16px;
      border: 1px solid var(--line);
      border-radius: 16px;
      background: #f8faf6;
      color: var(--text);
      font: inherit;
      font-weight: 800;
      padding: 0 14px;
      outline: none;
    }

    .mode-schedule-help {
      margin-top: 12px;
      color: var(--muted);
      font-size: 12px;
      font-weight: 800;
      line-height: 1.5;
    }

    .mode-month-control {
      margin-top: 14px;
      min-height: 42px;
      border-radius: 16px;
      background: var(--panel);
      box-shadow: var(--shadow);
      display: grid;
      grid-template-columns: 44px 1fr 44px;
      align-items: center;
      text-align: center;
      font-weight: 900;
    }

    .mode-schedule-grid {
      margin-top: 10px;
      flex: 1;
      min-height: 0;
      overflow: auto;
      display: grid;
      grid-template-columns: repeat(7, minmax(38px, 1fr));
      align-content: start;
      gap: 3px;
    }

    .mode-schedule-day,
    .mode-schedule-weekday {
      min-height: 42px;
      border-radius: 8px;
      background: var(--panel);
      display: grid;
      place-items: center;
      padding: 0 8px;
      font-size: 12px;
      font-weight: 900;
    }

    .mode-schedule-weekday {
      min-height: 30px;
      color: var(--muted);
      box-shadow: none;
    }

    .mode-schedule-day {
      min-height: 64px;
      touch-action: none;
      border: 1px solid var(--line);
    }

    .mode-schedule-day.outside-month {
      opacity: 0.42;
    }

    .mode-schedule-day.is-past {
      opacity: 0.32;
      cursor: not-allowed;
      filter: grayscale(1);
    }

    .mode-schedule-day.current-date {
      border-color: var(--green);
    }

    .mode-calendar-cell {
      align-content: center;
      gap: 3px;
      padding: 6px 4px;
      text-align: center;
      line-height: 1.15;
    }

    .mode-calendar-date {
      font-size: 15px;
      font-weight: 900;
    }

    .mode-calendar-label {
      width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 9px;
      font-weight: 900;
      color: var(--muted);
    }

    .mode-schedule-day.selected {
      background: var(--mode-color, var(--green));
      color: white;
      border-color: var(--mode-color, var(--green));
    }

    .mode-schedule-day.selected .mode-calendar-label,
    .mode-schedule-day.selected .mode-calendar-date {
      color: white;
    }

    .mode-schedule-day.editing-mode {
      box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .42);
    }

    body.dark-mode .mode-card,
    body.dark-mode .mode-back-button,
    body.dark-mode .mode-calendar-button,
    body.dark-mode .mode-schedule-day,
    body.dark-mode .mode-schedule-weekday {
      background: var(--panel);
    }

    body.dark-mode .mode-schedule-day.selected {
      background: var(--mode-color, var(--green));
    }

    @media (min-width: 768px) {
      .mode-page { height: 100%; }
    }
