:root {
      --bg: #08111f;
      --bg-elevated: #0d1728;
      --panel: rgba(15, 24, 39, 0.88);
      --panel-strong: #101a2d;
      --ink: #e7eefc;
      --muted: #97a7c4;
      --line: rgba(128, 157, 214, 0.18);
      --line-strong: rgba(128, 157, 214, 0.34);
      --accent: #6eaefc;
      --accent-2: #1d5dca;
      --accent-soft: rgba(29, 93, 202, 0.16);
      --warn: #ff8a5b;
      --danger: #ff6f7d;
      --success: #7bd0a3;
      --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
    }
    body {
      margin: 0;
      font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      background:
        radial-gradient(900px 420px at 12% -8%, rgba(47, 125, 246, 0.24) 0, transparent 58%),
        radial-gradient(760px 360px at 100% 0%, rgba(90, 162, 255, 0.14) 0, transparent 55%),
        linear-gradient(180deg, rgba(17, 29, 49, 0.92), rgba(8, 17, 31, 1)),
        var(--bg);
      color: var(--ink);
    }
    main {
      max-width: 1100px;
      margin: 0 auto;
      padding: 14px 16px 24px;
      display: grid;
      gap: 0;
    }
    h1, h2, h3 { margin: 0; line-height: 1.2; }
    h1 { font-size: clamp(1.28rem, 2.6vw, 1.72rem); letter-spacing: -0.03em; }
    h2 { font-size: 0.98rem; color: var(--ink); letter-spacing: -0.01em; }
    h3 { font-size: 0.86rem; color: var(--ink); }
    p { margin: 0; color: var(--muted); line-height: 1.42; }
    td, th { color: var(--muted); }
    .eyebrow {
      font-size: 10px;
      letter-spacing: 0.16em;
      text-transform: uppercase;
      color: var(--accent);
      font-weight: 700;
    }
    /* panels */
    .card {
      background: transparent;
      border: 0;
      border-radius: 0;
      box-shadow: none;
      backdrop-filter: none;
      padding: 12px 0;
    }
    .card + .card {
      border-top: 1px solid var(--line);
      margin-top: 6px;
      padding-top: 14px;
    }
    .card-header {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 4px;
    }
    .section-desc {
      font-size: 0.8rem;
      color: var(--muted);
      margin-bottom: 10px !important;
    }
    .subsection {
      border-top: 1px solid var(--line);
      margin-top: 10px;
      padding-top: 10px;
    }
    .subsection-header {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 10px;
    }
    .badge {
      font-size: 0.68rem;
      font-weight: 700;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      padding: 3px 8px;
      border-radius: 20px;
      background: rgba(47, 125, 246, 0.14);
      color: #8ebeff;
      border: 1px solid rgba(47, 125, 246, 0.22);
    }
    .badge.ics { background: rgba(47, 125, 246, 0.12); color: var(--accent); }
    .badge.planned { background: rgba(151, 167, 196, 0.1); color: var(--muted); }
    /* summary strip */
    .summary-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
      gap: 8px;
      margin-top: 8px;
    }
    .metric-card {
      background: transparent;
      border: 0;
      border-left: 2px solid rgba(47, 125, 246, 0.28);
      border-radius: 0;
      padding: 4px 0 4px 10px;
    }
    .metric { font-size: 1.32rem; font-weight: 700; color: var(--ink); }
    .metric-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
    /* toolbar */
    .toolbar {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 10px;
    }
    .page-nav {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 0;
      margin: 8px 0 10px;
      padding: 0 0 10px;
      border: 0;
      border-bottom: 1px solid var(--line);
      border-radius: 0;
      background: transparent;
      box-shadow: none;
    }
    .page-nav-link,
    .button-link {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border: 1px solid var(--line);
      background: transparent;
      color: var(--muted);
      padding: 10px 12px;
      border-radius: 0;
      font-size: 0.92rem;
      font-weight: 600;
      text-decoration: none;
      white-space: nowrap;
      min-width: 0;
      transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
    }
    .page-nav-link + .page-nav-link {
      border-left: 0;
    }
    .page-nav-link:hover {
      background: rgba(29, 93, 202, 0.08);
      border-color: var(--line-strong);
      color: var(--ink);
    }
    .page-nav-link.active {
      background: var(--accent-2);
      color: #fff;
      border-color: var(--accent-2);
      box-shadow: none;
    }
    /* forms */
    .inline-form {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      align-items: flex-start;
    }
    .form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
    .field-group { display: grid; gap: 4px; }
    .field-label { font-size: 0.78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
    input[type="text"], input[type="url"], input[type="search"], input[type="number"], textarea, select:not(.checkbox-wrap select) {
      border: 1px solid var(--line);
      background: rgba(8, 17, 31, 0.88);
      color: var(--ink);
      padding: 8px 10px;
      border-radius: 8px;
      font-size: 0.92rem;
    }
    textarea {
      min-height: 88px;
      resize: vertical;
      font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
      line-height: 1.4;
    }
    input[type="text"]:focus,
    input[type="url"]:focus,
    input[type="search"]:focus,
    input[type="number"]:focus,
    textarea:focus,
    select:focus {
      outline: none;
      border-color: rgba(90, 162, 255, 0.6);
      box-shadow: 0 0 0 3px rgba(47, 125, 246, 0.18);
    }
    input[type="text"] { min-width: 160px; }
    input[type="url"] { min-width: 280px; }
    input[type="search"] { min-width: 200px; }
    input[type="number"] { min-width: 120px; }
    select { min-width: 140px; }
    /* checkbox output picker */
    .checkbox-wrap {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }
    .checkbox-wrap label {
      display: flex;
      align-items: center;
      gap: 5px;
      font-size: 0.85rem;
      color: var(--ink);
      background: rgba(15, 24, 39, 0.88);
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 5px 10px;
      cursor: pointer;
      user-select: none;
    }
    .checkbox-wrap input[type="checkbox"] { accent-color: var(--accent-2); }
    /* output rules */
    .target-rules {
      display: grid;
      gap: 10px;
      grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      margin-top: 10px;
    }
    .target-rule {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: rgba(11, 19, 33, 0.92);
      padding: 10px;
      display: grid;
      gap: 6px;
    }
    .target-rule strong { color: var(--ink); font-size: 0.88rem; }
    .target-rule label { display: grid; gap: 3px; color: var(--muted); font-size: 0.78rem; }
    .target-rule input { min-width: 0; width: 100%; box-sizing: border-box; }
    /* buttons */
    button {
      border: 1px solid var(--line);
      background: rgba(16, 26, 45, 0.96);
      color: var(--ink);
      padding: 8px 12px;
      border-radius: 8px;
      font-size: 0.9rem;
      cursor: pointer;
      font-weight: 600;
      white-space: nowrap;
    }
    button.primary { background: linear-gradient(135deg, #1548ad, #1d5dca 58%, #236cda); color: #fff; border-color: transparent; }
    button.warn { background: rgba(255, 138, 91, 0.12); color: #ffb18d; border-color: rgba(255, 138, 91, 0.18); }
    button.danger { background: rgba(255, 111, 125, 0.12); color: #ff9ca6; border-color: rgba(255, 111, 125, 0.18); padding: 5px 9px; font-size: 0.82rem; }
    button:disabled { opacity: 0.5; cursor: not-allowed; }
    button:hover:not(:disabled),
    .button-link:hover {
      border-color: var(--line-strong);
      background: rgba(47, 125, 246, 0.1);
    }
    /* tables */
    .table-wrap { overflow-x: auto; margin-top: 8px; }
    table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
    th, td { padding: 7px 8px; text-align: left; border-bottom: 1px solid rgba(128, 157, 214, 0.1); white-space: nowrap; }
    th { font-size: 0.69rem; text-transform: uppercase; letter-spacing: 0.1em; color: #a8b8d5; }
    tbody tr:nth-child(even) { background: rgba(128, 157, 214, 0.05); }
    td .actions { display: flex; gap: 6px; }
    /* status */
    .status {
      padding: 9px 12px;
      border-radius: 8px;
      background: rgba(47, 125, 246, 0.12);
      color: #9cc3ff;
      border: 1px solid rgba(47, 125, 246, 0.22);
      font-size: 0.82rem;
    }
    .status.error { background: rgba(255, 111, 125, 0.12); color: #ffacb4; border-color: rgba(255, 111, 125, 0.2); }
    .hint { font-size: 0.76rem; color: var(--muted); }
    .status-stack { max-width: 28rem; }
    .status-stack summary {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      cursor: pointer;
      list-style: none;
    }
    .status-stack summary::-webkit-details-marker { display: none; }
    .status-stack-panel {
      margin-top: 4px;
      overflow: hidden;
      max-height: 240px;
      transition: max-height 180ms ease;
    }
    .status-stack-ok .status-stack-panel {
      max-height: 0;
      margin-top: 0;
    }
    .status-stack-ok[open] .status-stack-panel {
      max-height: 240px;
      margin-top: 4px;
    }
    .status-stack-body,
    .status-stack-detail {
      max-width: 28rem;
      white-space: normal;
      margin-top: 2px;
    }
    /* instance list (Modify Events) */
    .inst-results { display: grid; gap: 2px; margin-top: 10px; }
    .inst-row {
      display: grid;
      grid-template-columns: 140px 1fr auto;
      align-items: center;
      gap: 10px;
      padding: 6px 10px;
      border: 1px solid var(--line);
      border-radius: 5px;
      background: rgba(15, 24, 39, 0.88);
      cursor: pointer;
      font-size: 0.88rem;
    }
    .inst-row:hover { background: rgba(47, 125, 246, 0.08); border-color: var(--line-strong); }
    .inst-row.open { background: rgba(47, 125, 246, 0.12); border-color: var(--accent-2); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
    .inst-row-date { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
    .inst-row-title { font-weight: 600; color: var(--ink); }
    .inst-row-meta { font-size: 0.76rem; color: var(--muted); white-space: nowrap; }
    .inst-drawer {
      border: 1px solid var(--accent-2);
      border-top: none;
      border-radius: 0 0 6px 6px;
      background: rgba(9, 18, 31, 0.98);
      padding: 12px 14px;
      margin-bottom: 6px;
    }
    .inst-drawer h4 { font-size: 0.85rem; font-weight: 600; margin: 0 0 10px; color: var(--ink); }
    .inst-drawer .override-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin: 0; }
    .inst-drawer .override-list { margin-top: 10px; display: grid; gap: 6px; }
    .inst-drawer .override-item {
      display: flex; align-items: center; gap: 10px;
      padding: 6px 10px; border: 1px solid var(--line); border-radius: 5px;
      background: rgba(15, 24, 39, 0.94); font-size: 0.82rem;
    }
    .inst-drawer .override-item-info { flex: 1; }
    .inst-drawer .override-item-meta { font-size: 0.78rem; color: var(--muted); }
    .hidden { display: none !important; }
    .feed-debug-main {
      max-width: 1320px;
    }
    .feed-debug-toolbar {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
      gap: 10px;
      align-items: end;
      margin-top: 10px;
    }
    .feed-debug-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      align-items: center;
      justify-content: flex-end;
    }
    .feed-debug-summary {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 8px;
      margin-top: 14px;
    }
    .feed-metric-text {
      font-size: 0.94rem;
      line-height: 1.3;
      white-space: normal;
    }
    .feed-debug-contract {
      display: grid;
      gap: 6px;
      margin-top: 14px;
      padding: 10px 12px;
      border: 1px solid var(--line);
      background: rgba(10, 18, 32, 0.9);
      border-radius: 10px;
    }
    .feed-contract-label {
      font-size: 0.7rem;
      font-weight: 700;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      color: var(--muted);
    }
    .feed-debug-contract code {
      color: var(--ink);
      white-space: nowrap;
      overflow-x: auto;
    }
    .feed-debug-table-wrap {
      margin-top: 14px;
    }
    .feed-debug-table {
      table-layout: fixed;
    }
    .feed-debug-table th,
    .feed-debug-table td {
      vertical-align: top;
      white-space: normal;
      padding-top: 8px;
      padding-bottom: 8px;
    }
    .feed-cell-time,
    .feed-cell-uid {
      font-variant-numeric: tabular-nums;
      font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
      color: #bfd0ef;
    }
    .feed-cell-summary {
      min-width: 280px;
    }
    .feed-summary-primary {
      color: var(--ink);
      font-weight: 700;
    }
    .feed-summary-secondary {
      margin-top: 4px;
      font-size: 0.75rem;
      color: var(--muted);
      line-height: 1.45;
    }
    .feed-status-tag {
      display: inline-flex;
      align-items: center;
      border-radius: 999px;
      padding: 3px 8px;
      border: 1px solid var(--line);
      background: rgba(47, 125, 246, 0.1);
      color: #9cc3ff;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      font-size: 0.68rem;
      font-weight: 700;
    }
    .button-link[aria-disabled="true"] {
      pointer-events: none;
      opacity: 0.55;
    }

    .event-main {
      max-width: 720px;
    }
    .hero-card {
      position: static;
    }
    .mobile-focus-card {
      padding-bottom: 10px;
    }
    .event-filter-sticky {
      position: sticky;
      top: 0;
      z-index: 4;
      margin-top: 12px;
      margin-left: -2px;
      margin-right: -2px;
      padding: 10px 2px 8px;
      background: rgba(8, 17, 31, 0.98);
      border-bottom: 1px solid var(--line);
    }
    .event-filter-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px;
      margin-top: 0;
    }
    .event-search-group input {
      width: 100%;
      min-width: 0;
      box-sizing: border-box;
    }
    .mobile-inst-results {
      gap: 6px;
      margin-top: 14px;
    }
    .inst-card {
      border: 1px solid var(--line);
      border-radius: 10px;
      background: rgba(15, 24, 39, 0.9);
      padding: 9px 10px;
      display: grid;
      gap: 3px;
      box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
      cursor: pointer;
    }
    .inst-card.open {
      border-color: var(--accent-2);
      background: rgba(47, 125, 246, 0.08);
    }
    .inst-card-date {
      font-size: 0.8rem;
      color: var(--muted);
      font-variant-numeric: tabular-nums;
    }
    .inst-card-main {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 8px;
      align-items: center;
      min-width: 0;
    }
    .inst-card-title {
      font-size: 0.95rem;
      font-weight: 700;
      color: var(--ink);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .inst-card-meta {
      font-size: 0.82rem;
      color: var(--muted);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .inst-card-statuses {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-end;
      gap: 4px;
    }
    .status-pill {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border-radius: 999px;
      padding: 2px 7px;
      font-size: 0.7rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      white-space: nowrap;
      border: 1px solid transparent;
    }
    .status-pill-skip {
      background: rgba(255, 111, 125, 0.14);
      color: #ffb0b9;
      border-color: rgba(255, 111, 125, 0.2);
    }
    .status-pill-hidden {
      background: rgba(255, 175, 74, 0.14);
      color: #ffd39d;
      border-color: rgba(255, 175, 74, 0.2);
    }
    .status-pill-maybe {
      background: rgba(47, 125, 246, 0.16);
      color: #9cc3ff;
      border-color: rgba(47, 125, 246, 0.22);
    }
    .status-pill-note {
      background: rgba(123, 208, 163, 0.14);
      color: #ace4c4;
      border-color: rgba(123, 208, 163, 0.2);
    }
    .mobile-drawer {
      margin-top: 8px;
      border-top: 1px solid var(--line);
      padding: 12px 0 0;
      background: transparent;
      border-left: none;
      border-right: none;
      border-bottom: none;
      border-radius: 0;
    }
    .mobile-override-form {
      display: grid !important;
      gap: 10px !important;
      align-items: stretch !important;
    }
    .mobile-override-form input,
    .mobile-override-form select,
    .mobile-override-form button {
      width: 100%;
      min-width: 0;
      box-sizing: border-box;
    }
    .modified-events-list {
      display: grid;
      gap: 6px;
      margin-top: 10px;
    }
    .modified-item {
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 9px 10px;
      background: rgba(15, 24, 39, 0.9);
      display: grid;
      gap: 3px;
      cursor: pointer;
    }
    .modified-item.open {
      border-color: var(--accent-2);
      background: rgba(47, 125, 246, 0.08);
    }
    .modified-item-main {
      display: grid;
      grid-template-columns: auto minmax(0, 1fr) auto;
      align-items: center;
      gap: 8px;
      min-width: 0;
    }
    .modified-item-date,
    .modified-item-meta {
      font-size: 0.8rem;
      color: var(--muted);
      font-variant-numeric: tabular-nums;
    }
    .modified-item-title {
      font-weight: 700;
      color: var(--ink);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .modified-item-meta {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .modified-item-drawer {
      margin-top: 6px;
      cursor: default;
    }

    @media (max-width: 820px) {
      .event-filter-grid {
        grid-template-columns: 1fr;
      }
      .feed-debug-toolbar {
        grid-template-columns: 1fr 1fr;
      }
      .feed-debug-actions,
      .feed-debug-summary {
        grid-column: 1 / -1;
      }
      .feed-debug-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
    }

    @media (max-width: 640px) {
      main {
        padding: 12px 10px 22px;
      }
      .card {
        padding: 10px 0;
      }
      .card + .card {
        margin-top: 4px;
        padding-top: 12px;
      }
      .toolbar {
        flex-direction: column;
        align-items: stretch;
      }
      .toolbar button,
      .button-link,
      .page-nav-link {
        width: 100%;
        box-sizing: border-box;
      }
      .feed-debug-toolbar,
      .feed-debug-summary {
        grid-template-columns: 1fr;
      }
      .feed-debug-actions {
        justify-content: stretch;
      }
      .feed-debug-actions button,
      .feed-debug-actions .button-link {
        width: 100%;
        box-sizing: border-box;
      }
      .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
      .inst-row {
        grid-template-columns: 1fr;
        gap: 4px;
      }
      .inst-row-meta,
      .inst-row-date {
        white-space: normal;
      }
      .inst-drawer .override-form {
        display: grid;
        gap: 8px;
      }
      .inst-drawer .override-form input,
      .inst-drawer .override-form select,
      .inst-drawer .override-form button {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
      }
      .inst-drawer .override-item {
        align-items: flex-start;
        flex-direction: column;
      }
      .modified-item-main {
        grid-template-columns: auto minmax(0, 1fr) auto;
      }
    }
