    /* Modern Cool — logo-harmonized tokens（旧名称は互換のため維持） */
    :root {
      --paper: #F4F6F9;
      --paper-soft: #F8FAFC;
      --paper-deep: #E9EDF2;
      --surface: rgba(255, 255, 255, 0.96);
      --surface-raised: #FFFFFF;
      --surface-sunken: rgba(236, 240, 245, 0.84);

      --ink: #1A2330;
      --ink-strong: #10161E;
      --ink-soft: #4C5A6B;
      --ink-muted: #8593A3;

      /* Hairline rules */
      --hairline: rgba(26, 35, 48, 0.10);
      --hairline-strong: rgba(26, 35, 48, 0.20);
      --hairline-faint: rgba(26, 35, 48, 0.04);

      /* Accent — refined indigo */
      --aizome: #2B8FE8;
      --aizome-light: #5FACEE;
      --aizome-deep: #1D6FC0;
      --aizome-wash: rgba(43, 143, 232, 0.10);
      --aizome-tint: rgba(43, 143, 232, 0.04);

      /* Vermillion — reserved for danger / decorative accents */
      --shubai: #D4453E;
      --shubai-wash: rgba(212, 69, 62, 0.10);

      /* Status — restrained editorial palette */
      --status-info: #2B6CB0;
      --status-success: #2FA36B;
      --status-warning: #C98A2B;
      --status-danger: #D4453E;

      /* Annotation — vermilion, indigo, bellflower, young bamboo, sumi gray */
      --annot-hline: #D4453E;
      --annot-vline: #D4453E;
      --annot-cross: #2B8FE8;
      --annot-rect: #7A5CD6;
      --annot-selected: #2FA36B;
      --annot-excluded: #7A8494;
      --annot-line-preview: #E06B64;
      --annot-rect-preview: #9B83E3;
      --annot-measure: #667487;
      --annot-label-text: #FFFFFF;
      --annot-handle-fill: #FFFFFF;
      --annot-hline-fill: rgba(212, 69, 62, 0.10);
      --annot-hline-border: rgba(212, 69, 62, 0.22);
      --annot-cross-fill: rgba(43, 143, 232, 0.10);
      --annot-cross-border: rgba(43, 143, 232, 0.22);
      --annot-rect-fill: rgba(122, 92, 214, 0.10);
      --annot-rect-border: rgba(122, 92, 214, 0.24);
      --annot-selected-fill: rgba(47, 163, 107, 0.15);
      --annot-selected-border: rgba(47, 163, 107, 0.28);
      --annot-excluded-fill: rgba(122, 132, 148, 0.14);
      --annot-excluded-stroke: rgba(122, 132, 148, 0.38);
      --annot-trim-fill: rgba(122, 132, 148, 0.06);
      --annot-trim-stroke: rgba(122, 132, 148, 0.76);
      --annot-measure-fill: rgba(102, 116, 135, 0.90);

      /* Legacy aliases — keep existing rules working */
      --bg: var(--paper);
      --panel: var(--surface);
      --panel-strong: var(--surface-raised);
      --line: var(--hairline);
      --line-strong: var(--hairline-strong);
      --text: var(--ink);
      --sub: var(--ink-soft);
      --accent: var(--aizome);
      --danger: var(--status-danger);
      --purple: var(--annot-rect);
      --blue: var(--aizome);
      --green: var(--status-success);
      --page-bg: var(--paper-soft);

      /* Elevation — single restrained scale */
      --shadow-1: 0 1px 2px rgba(16, 22, 30, 0.04);
      --shadow-2: 0 4px 10px rgba(16, 22, 30, 0.05);
      --shadow-3: 0 14px 32px rgba(16, 22, 30, 0.09);
      --shadow: var(--shadow-3);

      /* Radius — controls 8 / containers 16 */
      --r-sm: 8px;
      --r-lg: 16px;

      /* Layout */
      --toolbar-h: 68px;
      --left-w: 320px;
      --right-w: 310px;
      --handle-w: 5px;

      /* Typography */
      --font-sans: "IBM Plex Sans JP", "Helvetica Neue", "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", sans-serif;
      --font-display: "IBM Plex Sans JP", "Helvetica Neue", "Hiragino Sans", "Yu Gothic UI", sans-serif;
      --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

      color-scheme: light;
    }

    [data-theme="dark"] {
      --paper: #12161D;
      --paper-soft: #171C24;
      --paper-deep: #0C1015;
      --surface: rgba(28, 35, 46, 0.92);
      --surface-raised: #232B38;
      --surface-sunken: rgba(15, 19, 26, 0.96);

      --ink: #E4EAF2;
      --ink-strong: #F2F6FB;
      --ink-soft: #9FACBD;
      --ink-muted: #6B7788;

      --hairline: rgba(228, 234, 242, 0.12);
      --hairline-strong: rgba(228, 234, 242, 0.24);
      --hairline-faint: rgba(228, 234, 242, 0.04);

      --aizome: #4FA9F2;
      --aizome-light: #7CC2F7;
      --aizome-deep: #2B8FE8;
      --aizome-wash: rgba(79, 169, 242, 0.14);
      --aizome-tint: rgba(79, 169, 242, 0.06);

      --shubai: #F08A80;
      --shubai-wash: rgba(240, 138, 128, 0.15);

      --status-info: #7BABD8;
      --status-success: #6FC79A;
      --status-warning: #E2B468;
      --status-danger: #F08A80;

      --annot-hline: #F08A80;
      --annot-vline: #F08A80;
      --annot-cross: #6FBBF5;
      --annot-rect: #A78BE8;
      --annot-selected: #6FC79A;
      --annot-excluded: #93A0AE;
      --annot-line-preview: #F4AAA3;
      --annot-rect-preview: #C1ABF0;
      --annot-measure: #93A0AE;
      --annot-label-text: #12161D;
      --annot-handle-fill: #171C24;
      --annot-hline-fill: rgba(240, 138, 128, 0.16);
      --annot-hline-border: rgba(240, 138, 128, 0.36);
      --annot-cross-fill: rgba(111, 187, 245, 0.16);
      --annot-cross-border: rgba(111, 187, 245, 0.36);
      --annot-rect-fill: rgba(167, 139, 232, 0.18);
      --annot-rect-border: rgba(167, 139, 232, 0.38);
      --annot-selected-fill: rgba(111, 199, 154, 0.18);
      --annot-selected-border: rgba(111, 199, 154, 0.38);
      --annot-excluded-fill: rgba(147, 160, 174, 0.18);
      --annot-excluded-stroke: rgba(147, 160, 174, 0.45);
      --annot-trim-fill: rgba(147, 160, 174, 0.10);
      --annot-trim-stroke: rgba(147, 160, 174, 0.78);
      --annot-measure-fill: rgba(147, 160, 174, 0.92);

      --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.30);
      --shadow-2: 0 4px 10px rgba(0, 0, 0, 0.40);
      --shadow-3: 0 14px 32px rgba(0, 0, 0, 0.55);
      --shadow: var(--shadow-3);

      color-scheme: dark;
    }

    @media (prefers-color-scheme: dark) {
      :root:not([data-theme]) {
        color-scheme: dark;
      }
    }

    * { box-sizing: border-box; }
    html, body { height: 100%; }
    body {
      margin: 0;
      font-family: var(--font-sans);
      font-feature-settings: "palt" 1, "ss01" 1;
      letter-spacing: 0.005em;
      color: var(--ink);
      background-color: var(--paper);
      overflow: hidden;
      position: relative;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
    }
    .app-shell { position: relative; z-index: 1; }

    .app-shell {
      display: grid;
      grid-template-rows: minmax(var(--toolbar-h), auto) minmax(0, 1fr) auto;
      gap: 6px;
      height: 100vh;
      padding: 12px;
      background: linear-gradient(var(--paper), var(--paper)) top / 100% 12px no-repeat;
    }

    .app-footer {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: 2px 12px;
      padding: 1px 8px;
      color: var(--ink-muted);
      font-size: 10px;
      line-height: 1.4;
      text-align: center;
    }

    .app {
      display: grid;
      grid-template-columns: var(--left-w) var(--handle-w) 1fr var(--handle-w) var(--right-w);
      grid-template-rows: minmax(0, 1fr);
      gap: 6px;
      min-height: 0;
      min-width: 0;
    }

    .glass {
      backdrop-filter: blur(14px) saturate(1.05);
      -webkit-backdrop-filter: blur(14px) saturate(1.05);
      background: var(--surface);
      border: 1px solid var(--hairline);
      box-shadow: var(--shadow-3);
    }

    .toolbar {
      width: 100%;
      min-width: 0;
      border-radius: var(--r-lg);
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
      padding: 12px 16px;
      gap: 14px;
      min-height: var(--toolbar-h);
    }

    .toolbar.brand-description-hidden .brand p {
      display: none;
    }

    .toolbar.toolbar-stacked {
      grid-template-columns: 1fr;
      align-items: flex-start;
    }

    .toolbar.toolbar-stacked .toolbar-actions {
      width: 100%;
      justify-content: flex-start;
      flex-wrap: wrap;
      overflow: visible;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 12px;
      min-width: 0;
      flex: 0 1 auto;
    }

    .brand-copy {
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 2px;
      overflow: hidden;
    }

    .brand-mark {
      width: 42px;
      height: 42px;
      display: grid;
      border-radius: var(--r-sm);
      place-items: center;
      overflow: hidden;
      background: var(--paper-soft);
      border: 1px solid var(--hairline);
      flex: 0 0 auto;
    }
    .brand-mark img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
      mix-blend-mode: multiply;
    }
    [data-theme="dark"] .brand-mark {
      background: var(--paper-deep);
    }
    [data-theme="dark"] .brand-mark img {
      mix-blend-mode: screen;
      filter: brightness(1.1) contrast(0.9);
    }

    .brand h1 {
      margin: 1px 0;
      font-family: var(--font-display);
      font-size: 22px;
      font-weight: 600;
      letter-spacing: 0.02em;
      color: var(--ink-strong);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .brand p {
      margin: 0;
      color: var(--ink-muted);
      font-family: var(--font-sans);
      font-size: 10.5px;
      font-weight: 400;
      letter-spacing: 0.04em;
      line-height: 1.5;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .toolbar-actions {
      display: flex;
      gap: 8px;
      flex-wrap: nowrap;
      justify-content: flex-end;
      align-items: center;
      flex: 0 0 auto;
      min-width: 0;
      margin-left: auto;
      overflow: hidden;
    }

    .sidebar, .workspace {
      border-radius: var(--r-lg);
      min-height: 0;
      min-width: 0;
      overflow: hidden;
    }

    #leftSidebar { grid-column: 1; grid-row: 1; }
    #leftResize { grid-column: 2; grid-row: 1; }
    .workspace { grid-column: 3; grid-row: 1; }
    #rightResize { grid-column: 4; grid-row: 1; }
    #rightSidebar { grid-column: 5; grid-row: 1; }

    .sidebar {
      display: flex;
      flex-direction: column;
      min-height: 0;
    }

    .sidebar-scroll {
      overflow: auto;
      overscroll-behavior: contain;
      padding: 14px 14px 28px;
      display: flex;
      flex-direction: column;
      gap: 12px;
      min-height: 0;
      min-width: 0;
    }

    .sidebar-handle {
      position: relative;
      cursor: col-resize;
      align-self: stretch;
      border-radius: var(--r-sm);
      background: transparent !important;
      border: none !important;
      box-shadow: none !important;
      backdrop-filter: none !important;
      -webkit-backdrop-filter: none !important;
    }

    .sidebar-handle::before {
      content: none;
    }

    .sidebar-handle:hover,
    .sidebar-handle.active {
      background: rgba(10,132,255,0.08) !important;
    }

    .workspace {
      padding: 12px;
      display: grid;
      grid-template-rows: auto 1fr;
      gap: 10px;
      background: var(--surface);
    }
    [data-theme="dark"] .workspace {
      background: var(--surface-sunken);
    }

    .panel {
      background: var(--surface-raised);
      border: 1px solid var(--hairline);
      border-radius: var(--r-lg);
      padding: 12px;
      box-shadow: var(--shadow-1);
    }

    .compact-panel {
      padding: 8px 10px;
    }

    .editor-topbar-panel {
      padding: 6px 8px;
      container-type: inline-size;
    }

    .panel h2, details summary {
      margin: 0;
      font-family: var(--font-sans);
      font-size: 12px;
      font-weight: 600;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--ink-soft);
    }
    .summary-label {
      color: var(--ink);
      text-transform: none;
      letter-spacing: 0.01em;
      font-size: 13px;
      font-weight: 600;
    }

    details.section-card {
      background: var(--surface-raised);
      border: 1px solid var(--hairline);
      border-radius: var(--r-lg);
      box-shadow: var(--shadow-1);
      overflow: visible;
      flex: 0 0 auto;
    }
    details.section-card[open] {
      border-color: var(--hairline-strong);
    }

    details.section-card > summary {
      list-style: none;
      cursor: pointer;
      padding: 10px 12px;
      display: grid;
      grid-template-columns: auto minmax(0, 1fr) auto auto;
      align-items: center;
      gap: 8px;
      user-select: none;
      min-width: 0;
    }

    details.section-card > summary::-webkit-details-marker { display: none; }
    .summary-label {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .summary-meta {
      color: var(--sub);
      font-size: 11px;
      font-weight: 600;
      flex-shrink: 0;
      justify-self: end;
    }
    .chevron {
      color: var(--sub);
      transition: transform 0.16s ease;
      width: 12px;
      height: 12px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }
    .chevron svg {
      width: 100%;
      height: 100%;
      fill: none;
      stroke: currentColor;
      stroke-width: 1.75;
      stroke-linecap: round;
      stroke-linejoin: round;
    }
    details[open] .chevron { transform: rotate(90deg); }
    .section-body {
      padding: 0 12px 14px;
      display: grid;
      gap: 10px;
      min-width: 0;
      overflow: visible;
    }

    .help-icon {
      appearance: none;
      border: 1px solid var(--hairline);
      background: var(--surface-raised);
      color: var(--ink-muted);
      width: 22px;
      height: 22px;
      border-radius: 999px;
      display: inline-grid;
      place-items: center;
      font-family: var(--font-display);
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      padding: 0;
      line-height: 1;
      justify-self: end;
      opacity: 0;
      pointer-events: none;
      transition: color 130ms ease, border-color 130ms ease, background 130ms ease, opacity 130ms ease;
    }

    details.section-card > summary:hover .help-icon,
    details.section-card > summary:focus-within .help-icon,
    .help-icon:focus-visible {
      opacity: 1;
      pointer-events: auto;
    }

    .help-icon:hover {
      color: var(--aizome);
      border-color: var(--aizome);
      background: var(--aizome-wash);
    }

    .help-note {
      display: none;
      padding: 12px 13px;
      border-radius: var(--r-lg);
      background: var(--aizome-tint);
      border: 1px solid var(--aizome-wash);
      box-shadow: var(--shadow-1);
      color: var(--ink-soft);
      font-size: 12px;
      line-height: 1.75;
    }

    .help-note.show {
      display: block;
    }

    .help-note strong,
    .help-note b {
      color: var(--text);
      font-weight: 800;
    }

    .help-note strong {
      display: block;
      margin-bottom: 6px;
      font-size: 12px;
    }

    .help-note ul {
      margin: 0;
      padding-left: 1.15em;
      display: grid;
      gap: 6px;
    }

    .help-note li {
      margin: 0;
    }

    .help-note .help-example {
      margin-top: 8px;
      padding-top: 8px;
      border-top: 1px dashed rgba(60,60,67,0.14);
      color: var(--sub);
      font-size: 11px;
      line-height: 1.7;
    }

    .help-note .kbd {
      background: var(--surface-raised);
      border: 1px solid var(--hairline-strong);
      border-radius: var(--r-sm);
      padding: 1px 6px;
      font-family: var(--font-mono);
      font-size: 11px;
      color: var(--ink);
    }

    .muted { color: var(--sub); font-size: 12px; line-height: 1.5; }
    .small { font-size: 11px; }

    .row {
      display: flex;
      gap: 8px;
      align-items: flex-start;
      flex-wrap: wrap;
      min-width: 0;
    }

    .row.spread { justify-content: space-between; }
    .row > * { min-width: 0; }

    .field {
      display: flex;
      flex-direction: column;
      gap: 6px;
      flex: 1;
      min-width: 0;
      padding: 9px 10px;
      border-radius: var(--r-sm);
      background: var(--paper-soft);
      border: 1px solid var(--hairline);
    }
    [data-theme="dark"] .field {
      background: var(--paper-deep);
    }

    .output-section .section-body {
      gap: 12px;
    }

    .output-summary-group,
    .output-settings-group {
      display: grid;
      gap: 10px;
      min-width: 0;
    }

    .output-summary-group {
      padding-bottom: 6px;
    }

    .output-settings-group {
      padding-top: 12px;
      border-top: 1px solid var(--hairline);
    }

    .output-section .info-list .summary-card {
      background: var(--surface-raised);
      border: 1px solid var(--hairline);
      box-shadow: none;
    }

    .output-section .field-interactive {
      background: var(--aizome-tint);
      border: 1px solid var(--aizome-wash);
      box-shadow: var(--shadow-1);
    }

    .output-section .field-interactive label {
      color: var(--aizome);
    }
    [data-theme="dark"] .output-section .field-interactive label {
      color: var(--aizome-light);
    }

    .output-scope-group {
      gap: 10px;
    }

    .output-range-row {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
      margin-top: 2px;
      padding-top: 10px;
      border-top: 1px solid rgba(10,132,255,0.14);
      align-items: stretch;
    }

    .output-range-row .field-subinput {
      min-width: 0;
      width: 100%;
      background: var(--surface-raised);
      border: 1px solid var(--hairline);
      box-shadow: none;
    }

    @media (max-width: 520px) {
      .output-range-row {
        grid-template-columns: 1fr;
      }
    }

    .mode-switch {
      display: inline-flex;
      gap: 3px;
      padding: 3px;
      border-radius: var(--r-sm);
      background: var(--paper-deep);
      border: 1px solid var(--hairline);
      align-items: center;
    }

    .mode-switch button {
      border: none;
      background: transparent;
      border-radius: var(--r-sm);
      padding: 6px 13px;
      font-family: var(--font-sans);
      font-size: 12px;
      font-weight: 500;
      color: var(--ink-soft);
      cursor: pointer;
      min-width: 0;
      transition: background 130ms ease, color 130ms ease;
    }
    .mode-switch button:hover { color: var(--ink); }

    .mode-switch button.active {
      background: var(--surface-raised);
      color: var(--aizome);
      font-weight: 600;
      box-shadow: var(--shadow-1);
    }
    [data-theme="dark"] .mode-switch button.active { color: var(--aizome-light); }

    .field label {
      font-size: 11px;
      color: var(--sub);
      font-weight: 700;
    }

    input[type="number"], input[type="text"], select {
      appearance: none;
      border: 1px solid var(--hairline-strong);
      border-radius: var(--r-sm);
      padding: 9px 11px;
      font-family: var(--font-mono);
      font-size: 12.5px;
      font-feature-settings: "tnum" 1;
      background: var(--surface-raised);
      color: var(--ink);
      outline: none;
      width: 100%;
      box-shadow: none;
      transition: border-color 130ms ease, box-shadow 130ms ease;
    }
    input[type="text"] {
      font-family: var(--font-sans);
      font-feature-settings: normal;
    }

    select {
      font-family: var(--font-sans);
      padding-right: 36px;
      background-color: var(--surface-raised);
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%234A4A52' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1.5 1.5L6 6l4.5-4.5'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 12px center;
      background-size: 12px 8px;
    }
    [data-theme="dark"] select {
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23B3AC9C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1.5 1.5L6 6l4.5-4.5'/%3E%3C/svg%3E");
    }

    input[type="number"]:focus,
    input[type="text"]:focus,
    select:focus {
      border-color: var(--aizome);
      box-shadow: 0 0 0 3px var(--aizome-wash);
    }

    input[type="file"] { display: none; }

    .button {
      appearance: none;
      border: 1px solid var(--hairline-strong);
      border-radius: var(--r-sm);
      padding: 8px 13px;
      min-height: 34px;
      font-family: var(--font-sans);
      font-size: 12px;
      font-weight: 500;
      letter-spacing: 0.02em;
      cursor: pointer;
      background: var(--surface-raised);
      color: var(--ink);
      box-shadow: var(--shadow-1);
      transition: transform 130ms ease, box-shadow 130ms ease, border-color 130ms ease, background-color 130ms ease, color 130ms ease, opacity 130ms ease;
      white-space: nowrap;
      line-height: 1.2;
    }

    .button:hover {
      transform: translateY(-1px);
      border-color: var(--ink-soft);
      box-shadow: var(--shadow-2);
    }
    .button:active { transform: translateY(0); box-shadow: var(--shadow-1); }
    .button:focus-visible {
      outline: none;
      border-color: var(--aizome);
      box-shadow: 0 0 0 3px var(--aizome-wash), var(--shadow-2);
    }
    /* Primary — aizome ink fill (final/save action) */
    .button.primary {
      color: var(--paper-soft);
      background: var(--aizome);
      border-color: var(--aizome-deep);
      box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    }
    .button.primary:hover {
      background: var(--aizome-deep);
      border-color: var(--aizome-deep);
      color: #fff;
    }
    [data-theme="dark"] .button.primary {
      color: var(--paper-deep);
      background: var(--aizome);
      border-color: var(--aizome-light);
    }
    [data-theme="dark"] .button.primary:hover {
      background: var(--aizome-light);
    }

    .button.secondary {
      background: var(--surface-raised);
    }

    /* Ghost + pressed — compact toggles use the segmented-control language. */
    .button.ghost {
      color: var(--ink-soft);
      background: transparent;
      border-color: var(--hairline);
      box-shadow: none;
    }
    .button.ghost:hover {
      background: var(--surface-raised);
      border-color: var(--hairline-strong);
    }
    .button.measurement-toggle {
      min-height: 32px;
      padding: 6px 11px;
      border-radius: var(--r-sm);
    }
    .button.ghost.is-on {
      color: var(--aizome);
      background: var(--surface-raised);
      border-color: var(--hairline);
      font-weight: 600;
      box-shadow: var(--shadow-1);
    }
    [data-theme="dark"] .button.ghost.is-on { color: var(--aizome-light); }

    .button.panel-toggle.is-on {
      color: var(--aizome);
      background: var(--aizome-wash);
      border-color: var(--aizome);
    }
    [data-theme="dark"] .button.panel-toggle.is-on { color: var(--aizome-light); }

    /* Upload — aizome outline (entry action) */
    .button.upload {
      color: var(--aizome);
      background: var(--surface-raised);
      border-color: var(--aizome);
      border-width: 1.5px;
      font-weight: 600;
    }
    .button.upload:hover {
      background: var(--aizome-wash);
      color: var(--aizome-deep);
      border-color: var(--aizome-deep);
    }
    [data-theme="dark"] .button.upload {
      color: var(--aizome-light);
      border-color: var(--aizome);
    }
    [data-theme="dark"] .button.upload:hover {
      background: var(--aizome-wash);
      color: var(--aizome-light);
    }

    .button.icon-only {
      min-width: 38px;
      padding: 8px 10px;
    }
    .button.icon-only.undo-redo {
      padding: 6px 8px;
      min-width: 40px;
    }
    .toolbar-svg-icon {
      width: 26px;
      height: 20px;
      display: block;
    }
    .button-icon, .theme-icon {
      font-size: 17px;
      font-weight: 500;
      line-height: 1;
      display: inline-block;
      transform: translateY(-0.5px);
      letter-spacing: -0.04em;
    }
    .theme-icon {
      font-size: 16px;
      transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
    }
    [data-theme="dark"] .theme-icon {
      transform: rotate(180deg);
    }

    /* Danger — shubai ink, text-led (used for "このページをクリア") */
    .button.danger {
      color: var(--shubai);
      background: var(--surface-raised);
      border-color: var(--shubai);
      border-width: 1.5px;
    }
    .button.danger:hover {
      background: var(--shubai-wash);
      color: var(--shubai);
      border-color: var(--shubai);
    }

    /* Purple — link action for 矩形 */
    .button.purple {
      color: #6B5C9C;
      background: var(--surface-raised);
      border-color: rgba(107, 92, 156, 0.55);
      border-width: 1.5px;
    }
    .button.purple:hover {
      background: rgba(107, 92, 156, 0.10);
      border-color: #5E548E;
    }
    [data-theme="dark"] .button.purple {
      color: #B0A0DC;
      border-color: rgba(176, 160, 220, 0.55);
    }

    /* Green — link action for エリア */
    .button.green {
      color: var(--status-success);
      background: var(--surface-raised);
      border-color: var(--status-success);
      border-width: 1.5px;
    }
    .button.green:hover {
      background: rgba(74, 107, 63, 0.10);
    }
    [data-theme="dark"] .button.green {
      color: var(--status-success);
      border-color: var(--status-success);
    }

    /* Blue — page-mata (subtle aizome outline variant) */
    .button.blue {
      color: var(--aizome);
      background: var(--surface-raised);
      border-color: var(--aizome);
      border-width: 1.5px;
    }
    .button.blue:hover {
      background: var(--aizome-wash);
      border-color: var(--aizome-deep);
    }

    .button[disabled],
    .button[aria-disabled="true"],
    .button[disabled]:hover,
    .button[aria-disabled="true"]:hover,
    .button[disabled]:active,
    .button[aria-disabled="true"]:active,
    .button[disabled]:focus-visible,
    .button[aria-disabled="true"]:focus-visible,
    [data-theme="dark"] .button[disabled],
    [data-theme="dark"] .button[aria-disabled="true"],
    [data-theme="dark"] .button[disabled]:hover,
    [data-theme="dark"] .button[aria-disabled="true"]:hover,
    [data-theme="dark"] .button[disabled]:active,
    [data-theme="dark"] .button[aria-disabled="true"]:active,
    [data-theme="dark"] .button[disabled]:focus-visible,
    [data-theme="dark"] .button[aria-disabled="true"]:focus-visible {
      opacity: 0.38;
      cursor: not-allowed;
      transform: none;
      color: var(--sub);
      background: transparent;
      border-color: var(--hairline);
      box-shadow: none;
    }

    .sidebar .button {
      white-space: normal;
      min-width: 0;
      flex: 0 1 auto;
      max-width: 100%;
      padding: 8px 10px;
      min-height: 32px;
      font-size: 11px;
    }

    .toolbar .button {
      white-space: nowrap;
      flex: 0 0 auto;
    }

    .segmented {
      display: inline-flex;
      flex-wrap: wrap;
      gap: 3px;
      padding: 3px;
      border-radius: var(--r-sm);
      background: var(--paper-deep);
      border: 1px solid var(--hairline);
      min-width: 0;
    }

    .segmented button {
      border: none;
      background: transparent;
      border-radius: var(--r-sm);
      padding: 6px 11px;
      font-family: var(--font-sans);
      font-size: 12px;
      font-weight: 500;
      color: var(--ink-soft);
      cursor: pointer;
      min-width: 0;
      transition: background 130ms ease, color 130ms ease;
    }
    .segmented button:hover {
      color: var(--ink);
    }

    .segmented button.active {
      background: var(--surface-raised);
      color: var(--aizome);
      font-weight: 600;
      box-shadow: var(--shadow-1);
    }
    [data-theme="dark"] .segmented button.active {
      color: var(--aizome-light);
    }


    .sidebar .segmented {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
      width: 100%;
    }

    .sidebar .segmented button {
      width: 100%;
      white-space: normal;
    }

    .topbar {
      display: flex;
      gap: 6px;
      align-items: center;
      flex-wrap: nowrap;
      min-width: 0;
    }

    .topbar-left {
      display: flex;
      flex: 0 0 auto;
      flex-wrap: nowrap;
      gap: 2px;
      align-items: center;
      min-width: 0;
    }

    .topbar-right {
      display: flex;
      gap: 6px;
      align-items: center;
      justify-content: flex-end;
      flex-wrap: nowrap;
      align-self: center;
      flex: 1 1 auto;
      min-width: 0;
    }

    .topbar-right > * { flex: 0 0 auto; }

    .page-navigation .page-nav-button {
      min-width: 32px;
      min-height: 30px;
      padding: 6px 7px;
      font-size: 13px;
    }

    .page-navigation .page-label {
      min-width: 42px;
      justify-content: center;
      gap: 0;
      padding: 6px 8px;
    }

    .topbar .mode-switch {
      gap: 2px;
      padding: 2px;
      border-radius: var(--r-sm);
    }

    .topbar .mode-switch button {
      padding: 5px 8px;
      font-size: 11px;
    }

    .zoom-controls {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      min-width: 0;
      padding: 3px 8px;
      border-radius: var(--r-sm);
      background: var(--paper-deep);
      border: 1px solid var(--hairline);
    }

    .zoom-slider {
      width: 120px;
      accent-color: var(--aizome);
      cursor: pointer;
    }

    .zoom-value {
      min-width: 44px;
      text-align: center;
      font-family: var(--font-mono);
      font-size: 11px;
      font-feature-settings: "tnum" 1;
      font-weight: 500;
      color: var(--ink-soft);
    }

    .selection-status { display: none !important; }

    @container (max-width: 700px) {
      .zoom-slider,
      .zoom-value { display: none; }

      .zoom-controls {
        gap: 4px;
        padding: 2px;
      }
    }

    @container (max-width: 540px) {
      .topbar,
      .topbar-right { gap: 4px; }

      .page-navigation .page-nav-button {
        min-width: 30px;
        padding: 6px;
      }

      .page-navigation .page-label {
        min-width: 40px;
        padding: 6px;
      }

      .topbar .mode-switch button { padding: 5px 6px; }

      .topbar .measurement-toggle {
        width: 30px;
        min-width: 30px;
        padding: 6px;
        font-size: 0;
        letter-spacing: 0;
        overflow: hidden;
      }

      .topbar .measurement-toggle::before {
        content: "↔";
        font-size: 15px;
        line-height: 1;
      }

      .topbar .button.icon-only.undo-redo {
        min-width: 30px;
        padding: 6px 5px;
      }

      .topbar .toolbar-svg-icon {
        width: 18px;
        height: 16px;
      }
    }

    .pill {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 6px 12px;
      border-radius: var(--r-sm);
      background: var(--paper-deep);
      border: 1px solid var(--hairline);
      font-family: var(--font-mono);
      font-size: 11.5px;
      font-feature-settings: "tnum" 1;
      font-weight: 500;
      color: var(--ink);
      letter-spacing: 0.04em;
    }

    .dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: var(--green);
      box-shadow: 0 0 0 4px rgba(48,209,88,0.15);
    }

    .viewer-shell {
      display: grid;
      grid-template-columns: 1fr;
      min-height: 0;
      gap: 10px;
    }

    .viewer {
      position: relative;
      min-height: 0;
      overflow: auto;
      touch-action: none;
      border-radius: var(--r-lg);
      border: 1px solid var(--hairline);
      background: var(--paper-soft);
      background-image:
        linear-gradient(var(--hairline-faint) 1px, transparent 1px),
        linear-gradient(90deg, var(--hairline-faint) 1px, transparent 1px);
      background-size: 24px 24px, 24px 24px;
      display: grid;
      place-items: center;
      padding: 16px;
    }
    [data-theme="dark"] .viewer {
      background: var(--paper-deep);
    }
    .viewer.dragover {
      box-shadow: inset 0 0 0 2px var(--aizome);
      background: var(--aizome-tint);
    }
    [data-theme="dark"] .viewer.dragover {
      box-shadow: inset 0 0 0 2px var(--aizome-light);
    }

    .empty {
      max-width: 680px;
      padding: 48px 28px;
      text-align: center;
      color: var(--ink-soft);
      line-height: 1.75;
      font-size: 13px;
      letter-spacing: 0.01em;
      display: grid;
      gap: 22px;
      place-items: center;
      animation: empty-fade 600ms ease-out;
    }
    @keyframes empty-fade {
      from { opacity: 0; transform: translateY(8px); }
      to { opacity: 1; transform: translateY(0); }
    }
    .empty-mark {
      display: inline-block;
      width: 92px;
      height: 116px;
      position: relative;
      opacity: 0.85;
    }
    .empty-mark svg {
      width: 100%;
      height: 100%;
      display: block;
    }
    .empty-mark .page {
      fill: var(--surface-raised);
      stroke: var(--ink-soft);
      stroke-width: 1.4;
    }
    .empty-mark .crop {
      stroke: var(--aizome);
      stroke-width: 1.6;
      fill: none;
    }
    .empty-mark .crop-h { stroke-dasharray: 3 4; }
    .empty-mark .crop-v { stroke-dasharray: 3 4; }
    .empty-mark .corner {
      stroke: var(--aizome);
      stroke-width: 1.8;
      fill: none;
    }
    [data-theme="dark"] .empty-mark .page {
      fill: var(--paper-soft);
    }

    .empty p {
      margin: 0;
      max-width: 540px;
    }
    .empty p strong {
      display: block;
      margin-bottom: 8px;
      color: var(--ink-strong);
      font-family: var(--font-display);
      font-size: 17px;
      font-weight: 600;
      letter-spacing: 0.04em;
    }
    .empty .empty-privacy {
      max-width: 540px;
      color: var(--ink-muted);
      font-size: 11px;
      line-height: 1.65;
    }
    .empty-steps {
      display: inline-flex;
      align-items: center;
      gap: 0;
      flex-wrap: wrap;
      justify-content: center;
      margin-top: 6px;
      padding: 10px 16px;
      border-radius: var(--r-sm);
      background: var(--surface-raised);
      border: 1px solid var(--hairline);
      font-family: var(--font-mono);
      font-size: 11px;
      letter-spacing: 0.04em;
      color: var(--ink-soft);
    }
    .empty-steps .step {
      padding: 2px 10px;
      white-space: nowrap;
    }
    .empty-steps .step-num {
      display: inline-block;
      min-width: 14px;
      color: var(--aizome);
      font-weight: 600;
      margin-right: 4px;
    }
    .empty-steps .arrow {
      color: var(--ink-muted);
      font-size: 10px;
      padding: 0 2px;
      user-select: none;
    }

    .canvas-wrap {
      position: relative;
      display: inline-block;
      user-select: none;
      -webkit-user-select: none;
      transform-origin: center center;
      will-change: transform;
      transition: transform 110ms ease-out;
    }

    .canvas-wrap.zooming {
      transition: none;
    }

    #pageCanvas {
      display: block;
      background: var(--page-bg);
      border-radius: var(--r-lg);
      box-shadow: var(--shadow-3), 0 0 0 1px var(--hairline);
      max-width: min(100%, 1100px);
      height: auto;
    }

    #overlayCanvas {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      cursor: crosshair;
    }

    .status-toast {
      position: absolute;
      right: 16px;
      top: 16px;
      display: inline-flex;
      align-items: center;
      gap: 10px;
      padding: 9px 14px 9px 12px;
      border-radius: var(--r-lg);
      background: var(--surface-raised);
      border: 1px solid var(--hairline-strong);
      border-left: 3px solid var(--aizome);
      box-shadow: var(--shadow-2);
      font-family: var(--font-sans);
      font-size: 12px;
      font-weight: 500;
      color: var(--ink);
      z-index: 25;
      pointer-events: none;
      opacity: 0;
      --toast-x: 0px;
      --toast-y: 0px;
      transform: translate(var(--toast-x), calc(var(--toast-y) - 8px));
      transition: opacity 0.22s ease, transform 0.22s ease;
      max-width: min(420px, calc(100% - 32px));
    }

    .status-toast.show {
      opacity: 1;
      transform: translate(var(--toast-x), var(--toast-y));
    }
    .status-toast.warning { border-left-color: var(--status-warning); }
    .status-toast.error { border-left-color: var(--status-danger); }
    .status-toast.success { border-left-color: var(--status-success); }
    .status-toast.info { border-left-color: var(--status-info); }
    .status-toast .dot {
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: var(--aizome);
      flex: 0 0 auto;
    }
    .status-toast.warning .dot { background: var(--status-warning); }
    .status-toast.error .dot { background: var(--status-danger); }
    .status-toast.success .dot { background: var(--status-success); }

    .delete-burst {
      position: absolute;
      left: 0;
      top: 0;
      z-index: 36;
      pointer-events: none;
      opacity: 0;
      --burst-x: 0px;
      --burst-y: 0px;
      transform: translate(calc(var(--burst-x) - 50%), calc(var(--burst-y) - 50%)) scale(0.58);
    }

    .delete-burst.show {
      animation: deleteBurstFade 520ms cubic-bezier(.2,.82,.25,1) forwards;
    }

    .delete-burst-ring {
      position: absolute;
      inset: -8px;
      border-radius: var(--r-lg);
      border: 2px solid rgba(255,69,58,0.30);
      background: radial-gradient(circle, rgba(255,69,58,0.14) 0%, rgba(255,69,58,0) 68%);
      transform: scale(0.74);
      opacity: 0;
    }

    .delete-burst.show .delete-burst-ring {
      animation: deleteBurstRing 520ms cubic-bezier(.2,.82,.25,1) forwards;
    }

    .delete-burst-badge {
      position: relative;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 54px;
      padding: 6px 10px;
      border-radius: var(--r-sm);
      background: linear-gradient(180deg, rgba(255,113,102,0.98), rgba(255,69,58,0.98));
      color: #fff;
      font-size: 10px;
      font-weight: 800;
      letter-spacing: 0.01em;
      box-shadow: 0 8px 16px rgba(255,69,58,0.20);
    }

    @keyframes deleteBurstFade {
      0% {
        opacity: 0;
        transform: translate(calc(var(--burst-x) - 50%), calc(var(--burst-y) - 50%)) scale(0.68);
      }
      14% {
        opacity: 1;
        transform: translate(calc(var(--burst-x) - 50%), calc(var(--burst-y) - 50%)) scale(1.02);
      }
      70% {
        opacity: 1;
      }
      100% {
        opacity: 0;
        transform: translate(calc(var(--burst-x) - 50%), calc(var(--burst-y) - 50%)) scale(1.12);
      }
    }

    @keyframes deleteBurstRing {
      0% {
        opacity: 0;
        transform: scale(0.72);
      }
      18% {
        opacity: 1;
      }
      100% {
        opacity: 0;
        transform: scale(1.28);
      }
    }

    .chips {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }

    .legend-chips {
      align-items: flex-start;
    }

    .chip {
      padding: 6px 11px 5px;
      border-radius: var(--r-sm);
      font-family: var(--font-sans);
      font-size: 11px;
      font-weight: 500;
      letter-spacing: 0.02em;
      border: 1px solid var(--hairline);
      background: var(--paper-deep);
      color: var(--ink-soft);
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }
    .chip::before {
      content: "";
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: currentColor;
      flex: 0 0 auto;
      opacity: 0.85;
    }
    .chip.red { background: var(--annot-hline-fill); color: var(--annot-hline); border-color: var(--annot-hline-border); }
    .chip.blue { background: var(--annot-cross-fill); color: var(--annot-cross); border-color: var(--annot-cross-border); }
    .chip.rect { background: var(--annot-rect-fill); color: var(--annot-rect); border-color: var(--annot-rect-border); }
    .chip.sel { background: var(--annot-selected-fill); color: var(--annot-selected); border-color: var(--annot-selected-border); }

    .pages-list {
      display: grid;
      gap: 8px;
      overflow: auto;
      min-height: 200px;
      max-height: 44vh;
      padding-right: 2px;
    }

    .pages-list.list .page-item {
      display: grid;
      grid-template-columns: 54px 1fr;
      gap: 10px;
      align-items: center;
      padding: 9px;
    }

    .pages-list.compact .page-item {
      display: grid;
      grid-template-columns: 34px 1fr;
      gap: 8px;
      align-items: center;
      padding: 7px 8px;
    }
    .pages-list.compact .page-thumb { width: 34px; height: 48px; border-radius: var(--r-sm); }
    .pages-list.compact .page-meta strong { font-size: 12px; margin-bottom: 2px; }
    .pages-list.compact .page-meta span { font-size: 10px; }

    .pages-list.icons {
      grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
      align-content: start;
    }
    .pages-list.icons .page-item {
      display: grid;
      gap: 6px;
      padding: 8px;
      justify-items: center;
    }
    .pages-list.icons .page-thumb { width: 72px; height: 100px; }
    .pages-list.icons .page-meta { text-align: center; }
    .pages-list.icons .page-meta span { display: none; }

    .page-item {
      border-radius: var(--r-sm);
      border: 1px solid var(--hairline);
      background: var(--surface-raised);
      cursor: pointer;
      transition: border-color 130ms ease, box-shadow 130ms ease;
    }
    .page-item:hover {
      border-color: var(--hairline-strong);
    }
    .page-item.active {
      border-color: var(--aizome);
      box-shadow: 0 0 0 3px var(--aizome-wash);
    }
    .page-thumb {
      width: 54px;
      height: 76px;
      object-fit: cover;
      border-radius: var(--r-sm);
      background: var(--paper-soft);
      border: 1px solid var(--hairline-strong);
    }
    .page-meta strong {
      display: block;
      font-size: 13px;
      margin-bottom: 4px;
    }
    .page-meta span {
      color: var(--sub);
      display: block;
      font-size: 11px;
      line-height: 1.45;
    }

    .stats-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }
    .stat {
      padding: 10px 12px;
      border-radius: var(--r-lg);
      background: rgba(255,255,255,0.98);
      border: 1px solid rgba(60,60,67,0.10);
    }
    .stat .label {
      display: block;
      font-size: 11px;
      color: var(--sub);
      margin-bottom: 4px;
      font-weight: 700;
    }
    .stat strong { font-size: 14px; }

    .list {
      display: grid;
      gap: 5px;
    }
    .info-list .list-item {
      background: var(--paper-deep);
      border-color: var(--hairline);
      box-shadow: none;
    }
    .info-list .list-item span {
      color: var(--ink-soft);
      font-weight: 500;
    }
    .info-list .list-item strong {
      color: var(--ink-strong);
      font-weight: 600;
    }
    .info-list .list-item strong.warning {
      color: var(--status-warning);
    }
    .list-item {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 6px;
      padding: 7px 9px;
      border-radius: var(--r-sm);
      background: var(--surface-raised);
      border: 1px solid var(--hairline);
      font-size: 12px;
      color: var(--ink);
    }
    .list-item.stack {
      display: grid;
      justify-content: stretch;
      gap: 5px;
    }
    .subsection-group {
      display: grid;
      gap: 5px;
      min-width: 0;
    }
    .subsection-heading {
      font-size: 11px;
      font-weight: 700;
      color: var(--sub);
      letter-spacing: 0.01em;
    }
    .line-sublist {
      max-height: min(16vh, 168px);
      min-height: 56px;
    }
    .list-item.active.line-item {
      border-color: var(--annot-hline-border);
      background: var(--annot-hline-fill);
      box-shadow: inset 0 0 0 1px var(--annot-hline-border);
    }
    .list-item.active.rect-item {
      border-color: var(--annot-rect-border);
      background: var(--annot-rect-fill);
      box-shadow: inset 0 0 0 1px var(--annot-rect-border);
    }
    .list-item.rect-item.other-page {
      background: var(--paper-deep);
      border-color: var(--hairline);
      opacity: 0.85;
    }
    .list-item.rect-item.other-page.active {
      background: var(--annot-rect-fill);
      border-color: var(--annot-rect-border);
    }
    .list-item.area-item {
      border-color: var(--annot-selected-border);
      background: var(--annot-selected-fill);
      box-shadow: inset 0 0 0 1px var(--annot-selected-border);
    }
    .list-item.area-item.active {
      border-color: var(--annot-selected-border);
      background: var(--annot-selected-fill);
      box-shadow: inset 0 0 0 1px var(--annot-selected-border);
    }
    .list-item.area-item.other-page {
      background: var(--paper-deep);
      border-color: var(--annot-selected-border);
      box-shadow: inset 0 0 0 1px var(--annot-selected-border);
    }
    .list-item.area-item.other-page.active {
      background: var(--annot-selected-fill);
      border-color: var(--annot-selected-border);
      box-shadow: inset 0 0 0 1px var(--annot-selected-border);
    }
    .list-item.area-link-item {
      border-color: var(--annot-selected-border);
      background: var(--annot-selected-fill);
      box-shadow: inset 0 0 0 1px var(--annot-selected-border);
    }
    .list-item.area-link-item .list-title,
    .list-item.area-item .list-title {
      color: var(--annot-selected);
    }
    .list-item.area-link-item .list-sub,
    .list-item.area-item .list-sub {
      color: var(--annot-selected);
    }
    .page-badge {
      display: inline-flex;
      align-items: center;
      padding: 1px 6px;
      border-radius: var(--r-sm);
      background: var(--aizome-wash);
      color: var(--aizome);
      font-family: var(--font-mono);
      font-size: 10px;
      font-weight: 500;
      flex-shrink: 0;
    }
    [data-theme="dark"] .page-badge { color: var(--aizome-light); }
    .area-badge {
      display: inline-flex;
      align-items: center;
      padding: 1px 6px;
      border-radius: var(--r-sm);
      background: rgba(74, 107, 63, 0.14);
      color: var(--status-success);
      font-family: var(--font-mono);
      font-size: 10px;
      font-weight: 500;
      flex-shrink: 0;
    }
    [data-theme="dark"] .area-badge {
      background: rgba(152, 195, 134, 0.18);
      color: #B5D6A4;
    }
    .rect-group-heading {
      font-size: 10px;
      font-weight: 700;
      color: var(--sub);
      letter-spacing: 0.01em;
      padding: 4px 0 1px;
    }
    .list-main {
      min-width: 0;
    }
    .list-title {
      font-weight: 700;
      margin-bottom: 1px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .list-sub {
      color: var(--sub);
      font-size: 10px;
      line-height: 1.4;
    }
    .mini-actions {
      display: flex;
      gap: 3px;
      align-items: center;
      flex-wrap: wrap;
    }
    .mini-button {
      border: 1px solid var(--hairline);
      background: var(--paper-deep);
      color: var(--ink-soft);
      border-radius: var(--r-sm);
      padding: 3px 8px;
      cursor: pointer;
      font-family: var(--font-sans);
      font-size: 10.5px;
      font-weight: 500;
      letter-spacing: 0.02em;
      transition: background 130ms ease, color 130ms ease, border-color 130ms ease;
    }
    .mini-button:hover {
      background: var(--aizome-wash);
      color: var(--aizome);
      border-color: var(--aizome);
    }
    [data-theme="dark"] .mini-button:hover {
      color: var(--aizome-light);
    }
    .mini-button.warn { color: var(--shubai); }
    .mini-button.warn:hover {
      background: var(--shubai-wash);
      color: var(--shubai);
      border-color: var(--shubai);
    }

    .list-title-row {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      min-width: 0;
    }
    .check-only {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      flex: 0 0 auto;
      padding: 0;
      margin: 0;
    }
    .check-only input {
      width: 14px;
      height: 14px;
      margin: 0;
      accent-color: var(--annot-rect);
    }
    .area-item .check-only input {
      accent-color: var(--annot-selected);
    }
    .link-badge {
      display: inline-flex;
      align-items: center;
      padding: 2px 7px;
      border-radius: var(--r-sm);
      background: var(--annot-rect-fill);
      color: var(--annot-rect);
      font-size: 10px;
      font-weight: 800;
    }
    .area-link-badge {
      display: inline-flex;
      align-items: center;
      padding: 2px 7px;
      border-radius: var(--r-sm);
      background: var(--annot-selected-fill);
      color: var(--annot-selected);
      font-size: 10px;
      font-weight: 800;
    }
    .thumb-modal-grid {
      display: grid;
      grid-template-columns: repeat(6, minmax(0, 1fr));
      gap: 14px;
      align-items: start;
    }
    .thumb-modal-item {
      display: grid;
      gap: 10px;
      padding: 12px;
      border-radius: var(--r-lg);
      border: 1px solid rgba(60,60,67,0.10);
      background: rgba(255,255,255,0.98);
      cursor: pointer;
      min-width: 0;
    }
    .thumb-modal-item:hover {
      border-color: rgba(10,132,255,0.28);
      box-shadow: 0 0 0 3px rgba(10,132,255,0.10);
    }
    .thumb-modal-item.active {
      border-color: rgba(10,132,255,0.34);
      box-shadow: 0 0 0 3px rgba(10,132,255,0.14);
    }
    .thumb-modal-item img {
      width: 100%;
      aspect-ratio: 1 / 1.4142;
      height: auto;
      object-fit: contain;
      justify-self: stretch;
      border-radius: var(--r-lg);
      border: 1px solid rgba(60,60,67,0.12);
      background: #fff;
      box-shadow: inset 0 0 0 1px rgba(255,255,255,0.7);
    }
    .thumb-modal-item strong {
      font-size: 13px;
    }
    .thumb-modal-item span {
      font-size: 11px;
      color: var(--sub);
    }

    .select-check {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 4px 8px;
      border-radius: var(--r-sm);
      background: rgba(255,255,255,0.82);
      border: 1px solid rgba(60,60,67,0.12);
      font-size: 11px;
      color: var(--sub);
      font-weight: 700;
      cursor: pointer;
      user-select: none;
    }
    .select-check input {
      width: 14px;
      height: 14px;
      margin: 0;
      accent-color: var(--accent);
    }

    .token-button.delete {
      color: #b42318;
      border-color: rgba(255,69,58,0.22);
      background: rgba(255,69,58,0.08);
    }
    .token-button.delete:hover {
      color: #b42318;
      border-color: rgba(255,69,58,0.28);
      background: rgba(255,69,58,0.14);
    }

    .segmented.icon-tabs {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .segmented.icon-tabs button {
      padding: 7px 8px;
      font-size: 15px;
      line-height: 1;
    }

    .toolbar-actions .panel-toggle {
      font-size: 14px;
    }

    .app.left-collapsed {
      grid-template-columns: 0 var(--handle-w) 1fr var(--handle-w) var(--right-w);
    }
    .app.right-collapsed {
      grid-template-columns: var(--left-w) var(--handle-w) 1fr var(--handle-w) 0;
    }
    .app.left-collapsed.right-collapsed {
      grid-template-columns: 0 var(--handle-w) 1fr var(--handle-w) 0;
    }
    .app.left-collapsed #leftSidebar,
    .app.right-collapsed #rightSidebar {
      display: none;
    }
    .app.left-collapsed #leftResize,
    .app.right-collapsed #rightResize {
      opacity: 0.35;
    }


    .scroll-list {
      max-height: min(34vh, 360px);
      min-height: 76px;
      overflow: auto;
      padding-right: 2px;
      align-content: start;
    }

    .token-palette {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }

    .token-button {
      border: 1px solid rgba(60,60,67,0.12);
      background: rgba(255,255,255,0.92);
      color: var(--sub);
      border-radius: var(--r-sm);
      padding: 6px 9px;
      min-height: 30px;
      cursor: pointer;
      font-size: 11px;
      font-weight: 700;
      line-height: 1;
      box-shadow: 0 4px 10px rgba(17,24,39,0.05);
    }

    .token-button:hover {
      color: var(--accent);
      border-color: rgba(10,132,255,0.22);
      background: rgba(10,132,255,0.08);
    }

    .drop-overlay {
      position: fixed;
      inset: 0;
      display: none;
      align-items: center;
      justify-content: center;
      background: rgba(15,23,42,0.16);
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
      z-index: 120;
      pointer-events: none;
    }
    .drop-overlay.show { display: flex; }
    .drop-card {
      min-width: min(460px, calc(100vw - 48px));
      padding: 26px 28px;
      border-radius: var(--r-lg);
      background: rgba(255,255,255,0.98);
      border: 2px dashed var(--annot-selected-border);
      box-shadow: 0 18px 40px rgba(15,23,42,0.16);
      text-align: center;
    }
    .drop-card strong {
      display: block;
      font-size: 18px;
      margin-bottom: 6px;
    }
    .drop-card .muted { font-size: 13px; }

    .loading {
      display: none;
      position: absolute;
      inset: 0;
      background: rgba(244,245,247,0.56);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      border-radius: var(--r-lg);
      place-items: center;
      z-index: 30;
    }
    .loading.show { display: grid; }
    .loading-card {
      background: rgba(255,255,255,0.9);
      border: 1px solid rgba(255,255,255,0.8);
      border-radius: var(--r-lg);
      padding: 16px 18px;
      box-shadow: var(--shadow);
      min-width: 230px;
      text-align: center;
    }
    .loading-actions {
      display: flex;
      justify-content: center;
      margin-top: 12px;
    }
    body.is-processing button:not(#cancelProcessingBtn),
    body.is-processing input,
    body.is-processing select,
    body.is-processing label[for="pdfInput"] {
      pointer-events: none;
    }
    .spinner {
      width: 28px;
      height: 28px;
      margin: 0 auto 10px;
      border-radius: 50%;
      border: 3px solid rgba(10,132,255,0.16);
      border-top-color: var(--accent);
      animation: spin 1s linear infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    .kbd {
      display: inline-block;
      padding: 2px 8px;
      border-radius: var(--r-sm);
      background: rgba(120,120,128,0.12);
      border: 1px solid rgba(60,60,67,0.12);
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      font-size: 11px;
      color: var(--sub);
    }

    .modal {
      position: fixed;
      inset: 0;
      display: none;
      align-items: center;
      justify-content: center;
      background: rgba(20, 18, 22, 0.42);
      backdrop-filter: blur(10px) saturate(0.85);
      -webkit-backdrop-filter: blur(10px) saturate(0.85);
      z-index: 80;
      padding: 20px;
      animation: modal-overlay-fade 180ms ease-out;
    }
    [data-theme="dark"] .modal {
      background: rgba(10, 8, 14, 0.65);
    }
    @keyframes modal-overlay-fade {
      from { opacity: 0; }
      to { opacity: 1; }
    }
    .modal.show { display: flex; }
    .modal-card {
      width: min(1540px, 100%);
      max-height: min(88vh, 1000px);
      border-radius: var(--r-lg);
      overflow: hidden;
      display: grid;
      grid-template-rows: auto 1fr;
      background: var(--surface-raised);
      border: 1px solid var(--hairline);
      box-shadow: var(--shadow-3), 0 0 0 1px var(--hairline-faint);
      animation: modal-card-rise 280ms cubic-bezier(0.22, 1, 0.36, 1);
    }
    @keyframes modal-card-rise {
      from { opacity: 0; transform: translateY(14px) scale(0.985); }
      to { opacity: 1; transform: translateY(0) scale(1); }
    }
    .modal-header, .modal-footer {
      padding: 14px 18px;
      border-bottom: 1px solid var(--hairline);
      background: var(--surface);
    }
    .modal-footer {
      border-top: 1px solid rgba(60,60,67,0.08);
      border-bottom: none;
      display: flex;
      justify-content: space-between;
      gap: 10px;
      flex-wrap: wrap;
      align-items: center;
    }
    .modal-body {
      padding: 16px;
      overflow: auto;
      background: rgba(248,249,251,0.94);
    }
    .notify-modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.5);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 1000;
    }
    .modal-card-confirm {
      max-width: 480px;
      width: 90%;
      background: var(--surface, #fff);
      border-radius: var(--r-lg);
      padding: 1.5rem;
      box-shadow: 0 8px 32px rgba(0,0,0,0.18);
      display: block;
    }
    .modal-card-title {
      font-size: 1.1rem;
      font-weight: 600;
      margin: 0 0 0.75rem;
    }
    .modal-card-body {
      margin: 0 0 1.25rem;
      line-height: 1.6;
    }
    .modal-card-footer {
      display: flex;
      gap: 0.75rem;
      justify-content: flex-end;
    }
    .preview-grid {
      display: grid;
      grid-template-columns: repeat(6, minmax(0, 1fr));
      gap: 14px;
      align-items: start;
    }
    .preview-card {
      border-radius: var(--r-lg);
      padding: 12px;
      background: rgba(255,255,255,0.92);
      border: 1px solid rgba(60,60,67,0.10);
      display: grid;
      gap: 10px;
      transition: border-color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
    }
    .preview-card:hover {
      border-color: rgba(10,132,255,0.28);
      box-shadow: 0 0 0 3px rgba(10,132,255,0.10);
      transform: translateY(-1px);
    }
    .preview-card:focus-within {
      border-color: rgba(10,132,255,0.30);
      box-shadow: 0 0 0 3px rgba(10,132,255,0.12);
    }
    .preview-thumb-button {
      appearance: none;
      border: none;
      padding: 0;
      margin: 0;
      background: transparent;
      border-radius: var(--r-sm);
      cursor: zoom-in;
      display: block;
      text-align: left;
    }
    .preview-thumb-button:focus-visible {
      outline: 2px solid rgba(10,132,255,0.5);
      outline-offset: 2px;
    }
    .preview-card img {
      width: 100%;
      aspect-ratio: 1 / 1.4142;
      height: auto;
      object-fit: contain;
      justify-self: stretch;
      border-radius: var(--r-lg);
      background: #fff;
      border: 1px solid rgba(60,60,67,0.10);
      box-shadow: inset 0 0 0 1px rgba(255,255,255,0.7);
    }
    .preview-thumb-button:hover img {
      border-color: rgba(10,132,255,0.22);
      box-shadow: inset 0 0 0 1px rgba(255,255,255,0.7), 0 0 0 3px rgba(10,132,255,0.08);
    }
    .preview-name-input {
      font-size: 12px;
      font-weight: 700;
      word-break: break-all;
      min-width: 0;
    }
    .preview-sub {
      color: var(--sub);
      font-size: 11px;
      line-height: 1.45;
    }

    .image-preview-card {
      width: min(1400px, 100%);
      max-height: min(92vh, 1200px);
      grid-template-rows: auto 1fr;
    }
    .image-preview-body {
      padding: 18px;
      display: grid;
      place-items: center;
      background: rgba(244,246,250,0.96);
    }
    .image-preview-stage {
      width: 100%;
      height: 100%;
      min-height: min(72vh, 820px);
      display: grid;
      place-items: center;
      border-radius: var(--r-lg);
      background: rgba(255,255,255,0.86);
      border: 1px solid rgba(60,60,67,0.08);
      padding: 18px;
      overflow: auto;
    }
    .image-preview-stage img {
      max-width: 100%;
      max-height: 78vh;
      object-fit: contain;
      border-radius: var(--r-lg);
      background: #fff;
      border: 1px solid rgba(60,60,67,0.10);
      box-shadow: 0 24px 48px rgba(15,23,42,0.12);
    }
    .image-preview-meta {
      color: var(--sub);
      font-size: 12px;
      line-height: 1.45;
      margin-top: 4px;
    }

    #imagePreviewModal {
      z-index: 92;
    }

    @media (max-width: 1640px) {
      .preview-grid,
      .thumb-modal-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
      }
    }
    @media (max-width: 1360px) {
      .preview-grid,
      .thumb-modal-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
      }
    }
    @media (max-width: 1120px) {
      .preview-grid,
      .thumb-modal-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
      }
    }
    @media (max-width: 860px) {
      .preview-grid,
      .thumb-modal-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
    }

    .hidden { display: none !important; }

    .restore-banner {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      padding: 0.75rem 1rem;
      background: var(--surface, #fff);
      border: 1px solid var(--border, #e5e7eb);
      border-radius: var(--r-lg);
      margin-bottom: 0.75rem;
      box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }
    .restore-banner-msg {
      flex: 1;
      font-size: 0.9rem;
    }
    .btn-sm {
      font-size: 0.8rem;
      padding: 0.3rem 0.75rem;
    }

    .app-fatal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.85);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      z-index: 9999;
      color: #fff;
      text-align: center;
      padding: 2rem;
      gap: 1rem;
    }
    .app-fatal-overlay h2 {
      font-size: 1.5rem;
      margin: 0;
    }
    .app-fatal-overlay p {
      max-width: 480px;
      opacity: 0.85;
    }

    @media (max-width: 980px) {
      body { overflow: auto; }
      .app-shell {
        height: auto;
        min-height: 100vh;
      }
      .app {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
      }
      .sidebar-handle { display: none; }
      #leftSidebar,
      .workspace,
      #rightSidebar {
        grid-column: 1;
      }
      #leftSidebar { grid-row: 1; }
      .workspace { grid-row: 2; }
      #rightSidebar { grid-row: 3; }
      .sidebar, .workspace { min-height: 440px; }
    }
