@layer components {
  .panel-body { display: grid; gap: var(--space-5); padding: var(--space-5); }
  .panel-body h2 { font-family: var(--font-display); font-size: var(--text-lg); letter-spacing: -0.02em; padding-inline-end: 2.75rem; }
  .panel-body h3 { font-size: var(--text-sm); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
  .panel-sec { display: grid; gap: var(--space-3); }
  .ticket-row {
    display: grid; gap: var(--space-2);
    padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
  }
  .ticket-row input[type="text"] {
    min-height: 44px; width: 100%; border: 1px solid var(--border); background: var(--surface);
    color: var(--text); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); font: inherit;
  }
  #survey .lbl { white-space: normal; }
  .survey-note textarea {
    width: 100%; min-height: 4.5rem; resize: vertical; font: inherit; color: var(--text);
    border: 1px solid var(--border); background: var(--surface);
    border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3);
  }
  .ticket-acts { display: flex; flex-wrap: wrap; gap: var(--space-1); }
  .ticket-acts .danger { margin-inline-start: auto; }
  .ghost.danger { color: var(--now); }
  .ghost.btn-icon svg {
    width: 18px; height: 18px;
    fill: none; stroke: currentColor; stroke-width: 1.75;
    stroke-linecap: round; stroke-linejoin: round;
  }

  .file-btn, #new-ticket-name, #notify-mins, #share-name, #share-url, #survey-source {
    min-height: 44px; width: 100%; font: inherit; color: var(--text);
    border: 1px solid var(--border); background: var(--surface);
    border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3);
  }
  #qr-box { min-height: 16rem; overflow: hidden; border-radius: var(--radius-sm); background: var(--bg); }
  #qr-box video { width: 100% !important; }
  .qr-show {
    display: grid; justify-items: center; gap: var(--space-3);
    min-inline-size: 0; max-inline-size: 100%; overflow: hidden;
    padding: var(--space-4); background: #fff; border-radius: var(--radius-sm);
  }
  .qr-show canvas, .qr-show img {
    display: block; width: min(16rem, 100%); max-inline-size: 100%;
    min-inline-size: 0; height: auto;
  }
  #share-qr-box { min-block-size: min(18rem, 40dvh); }
  .qr-payload { font-size: var(--text-xs); color: #333; word-break: break-all; text-align: center; max-width: 20rem; }

  #detail, #settings, #ticket-card, #res-card, #rates-card, #share, #saved, #scan, #survey {
    width: min(40rem, calc(100vw - 1.5rem)); max-height: min(90dvh, 52rem);
    background: var(--surface); color: var(--text); border-radius: var(--radius-md);
    box-shadow: var(--shadow-dialog); overflow: hidden;
  }
  #detail[open], #settings[open], #ticket-card[open], #res-card[open], #rates-card[open], #share[open], #saved[open], #scan[open], #survey[open] {
    display: flex; flex-direction: column;
  }
  #detail > article, #settings > .panel-body, #ticket-card > .panel-body, #res-card > .panel-body, #rates-card > .panel-body, #share > .panel-body, #saved > .panel-body, #scan > .panel-body, #survey > .panel-body {
    overflow: auto; min-height: 0; min-inline-size: 0; flex: 1 1 auto;
  }
  #scan { width: min(26rem, calc(100vw - 1.5rem)); }
  #detail::backdrop, #settings::backdrop, #ticket-card::backdrop, #res-card::backdrop, #rates-card::backdrop, #share::backdrop, #saved::backdrop, #scan::backdrop, #survey::backdrop, #busy::backdrop { background: var(--overlay); }

  .rate-list { display: grid; gap: var(--space-2); min-inline-size: 0; }
  .rate-item .rate-score {
    display: inline-flex; align-items: baseline; gap: 1px;
    color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums;
  }
  .rate-item .rate-score svg { width: 15px; height: 15px; align-self: center; fill: currentColor; stroke: none; margin-inline-end: 3px; }
  .rate-item .rate-score b { font-size: var(--text-lg); line-height: 1; }
  .rate-item .rate-score small { color: var(--text-faint); font-weight: 500; }
  .rate-item .sub { white-space: normal; }
  .rate-orphan { cursor: default; opacity: 0.85; }

  .res-log { display: grid; gap: var(--space-2); margin: 0; padding-inline-start: 1.2rem; font-size: var(--text-sm); color: var(--text-muted); }
  #res-fav-form { display: grid; gap: var(--space-5); }
  .res-fav-list {
    display: grid; gap: var(--space-2);
    margin: 0; padding: 0; border: 0; min-inline-size: 0;
  }
  .res-fav-row {
    align-items: start;
    padding: var(--space-3);
    border: 1px solid var(--border);
    background: var(--surface-2);
  }
  .res-fav-row:hover { background: var(--surface-3); }
  .res-fav-row input { margin-block-start: 0.2em; }
  .res-fav-row .n { display: block; font-family: var(--font-display); font-weight: 600; line-height: 1.25; }
  .res-fav-row .sub { display: block; font-size: var(--text-xs); color: var(--text-faint); }
  .res-fav-row .occ { display: block; font-size: var(--text-xs); font-variant-numeric: tabular-nums; color: var(--accent); }
  .res-fav-row .occ.is-off { color: var(--text-faint); }
  .res-fav-row .res-mark { display: block; font-size: var(--text-xs); font-weight: 600; color: var(--accent); }
  .res-fav-row.is-booked { box-shadow: inset 3px 0 0 var(--accent); }
  .res-fav-row:has(input:disabled) { opacity: 0.72; }
  #res-fav-form .seg { width: max-content; }
  #res-fav-max { position: sticky; top: 0; z-index: 1; background: var(--surface); padding-block: var(--space-2); }
  .poster { aspect-ratio: 16 / 10; background: var(--bg); overflow: hidden; }
  .poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .detail-body { display: grid; gap: var(--space-4); padding: var(--space-5); }
  .detail-body h2 {
    font-family: var(--font-display); font-size: clamp(1.4rem, 1.2rem + 1vw, 2rem);
    letter-spacing: -0.02em; line-height: 1.15; text-wrap: balance;
  }
  .orig { color: var(--text-muted); font-style: italic; }
  .meta { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); font-size: var(--text-sm); color: var(--text-muted); }
  .meta b { color: var(--text); font-weight: 600; }
  .friends {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
    font-size: var(--text-sm); color: var(--text-muted);
  }
  .friends button {
    min-height: 44px; padding: var(--space-1) var(--space-3);
    border: 1px solid var(--border); border-radius: 99px;
    background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600;
  }
  .friends button:hover { background: var(--surface-3); }
  .ratings { display: flex; flex-wrap: wrap; gap: var(--space-2); }
  .rate {
    display: inline-flex; align-items: baseline; gap: var(--space-2);
    min-height: 44px; padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--text); text-decoration: none; font-weight: 600;
  }
  button.rate { font: inherit; }
  .rate:hover { background: var(--surface-3); }
  .rate b { color: var(--accent); font-variant-numeric: tabular-nums; }
  .rate.is-wait { color: var(--text-muted); font-weight: 500; }
  .rate.is-link { color: var(--text-muted); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
  .rate svg { width: 12px; height: 12px; align-self: center; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
  .rate.is-on { box-shadow: inset 3px 0 0 var(--accent); }
  .rate:disabled { opacity: 0.55; cursor: not-allowed; }
  .syn { max-width: 65ch; text-wrap: pretty; }
  .credits { color: var(--text-muted); font-size: var(--text-sm); white-space: pre-wrap; }
  .detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
  .res-area { display: contents; }
  .res-state {
    display: inline-flex; align-items: center; min-height: 44px; padding-inline: var(--space-3);
    border-radius: var(--radius-sm); background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent);
    color: var(--accent); font-weight: 600;
  }
  .res-hint { flex-basis: 100%; order: 9; margin: 0; font-size: var(--text-sm); color: var(--text-muted); }
  .lnk-ext { display: inline-flex; align-items: center; gap: var(--space-1); min-height: 44px; text-decoration: underline; text-underline-offset: 3px; }
  .lnk-ext svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-height: 44px; padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm); border: 0; font-weight: 600; cursor: pointer;
    background: var(--accent); color: var(--accent-fg); text-decoration: none;
  }
  .btn:hover { background: oklch(from var(--accent) calc(l + 0.05) c h); }
  .btn.secondary { background: var(--surface-3); color: var(--text); }
  .btn-icon { width: 44px; padding-inline: 0; }
  .btn-icon svg { stroke-linecap: round; stroke-linejoin: round; }
  .saved-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
  .saved-list button {
    display: grid; gap: var(--space-1); width: 100%; min-height: 44px;
    padding: var(--space-3); text-align: start; font: inherit; color: inherit; cursor: pointer;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
  }
  .saved-list button:hover { background: var(--surface-3); }
  .saved-name { font-weight: 600; overflow-wrap: anywhere; }
  .saved-list .when { font-size: var(--text-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; }
  .btn svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.75; }
  .sr-file {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  .btn[aria-pressed="true"] { color: var(--accent); }
  .btn:not(.secondary)[aria-pressed="true"] { color: var(--accent-fg); }
  .btn[aria-pressed="true"] svg { fill: currentColor; }
  form:has(> .x) {
    position: absolute; inset-block-start: var(--space-3); inset-inline-end: var(--space-3); z-index: 2;
  }
  .x {
    width: 44px; height: 44px; border: 0; border-radius: 99px;
    background: oklch(0.12 0.02 55 / 0.6); color: var(--text);
  }
  details.more { color: var(--text-muted); font-size: var(--text-sm); }
  details.more summary { cursor: pointer; }
  .adv { border-block-start: 1px solid var(--border); }
  .adv > summary {
    display: flex; align-items: center; gap: var(--space-2);
    min-height: 44px; cursor: pointer; list-style: none;
  }
  .adv > summary::-webkit-details-marker { display: none; }
  .adv > summary::before {
    content: ""; flex: none; width: 0.4em; height: 0.4em;
    border-inline-end: 2px solid var(--text-muted);
    border-block-end: 2px solid var(--text-muted);
    transform: rotate(-45deg); margin-block-start: -0.15em;
  }
  .adv[open] > summary::before { transform: rotate(45deg); margin-block-start: 0; }
  .adv > summary h3 { margin: 0; }
  .adv .panel-sec { margin-block-start: var(--space-3); }
  .adv-warn { margin: 0; font-size: var(--text-sm); color: var(--now); text-wrap: pretty; }

  .mine {
    margin: 0; min-inline-size: 0; padding: 0;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
  }
  .mine summary {
    display: flex; align-items: center; gap: var(--space-2);
    min-height: 44px; padding: var(--space-2) var(--space-4);
    cursor: pointer; font-weight: 600; list-style: none;
  }
  .mine summary::-webkit-details-marker { display: none; }
  .mine summary::before {
    content: ""; flex: none; width: 0.4em; height: 0.4em;
    border-inline-end: 2px solid var(--text-muted);
    border-block-end: 2px solid var(--text-muted);
    transform: rotate(-45deg); margin-block-start: -0.15em;
  }
  .mine[open] summary::before { transform: rotate(45deg); margin-block-start: 0; }
  .mine[open] summary { border-block-end: 1px solid var(--border); }
  .mine-body { display: grid; gap: var(--space-3); padding: var(--space-4); }
  .mine-early { font-size: var(--text-sm); color: var(--now); text-wrap: pretty; }
  .mine-stars { display: grid; grid-template-columns: repeat(10, minmax(24px, 1fr)); max-width: 22rem; }
  .mine-stars button {
    min-height: 44px; min-width: 24px; padding: 0; border: 0;
    background: transparent; color: var(--text-muted);
  }
  .mine-stars button svg {
    width: 1.35rem; height: 1.35rem;
    fill: none; stroke: currentColor; stroke-width: 1.85; stroke-linejoin: round;
  }
  .mine-stars button.is-on { color: var(--accent); }
  .mine-stars button.is-on svg { fill: currentColor; }
  .mine-stars button:hover { color: var(--text); }
  .mine-stars button.is-on:hover { color: var(--accent); }
  .mine-n { margin-inline-start: auto; font-variant-numeric: tabular-nums; color: var(--accent); min-width: 2ch; text-align: end; }
  .mine label { font-size: var(--text-sm); font-weight: 600; }
  .mine textarea {
    width: 100%; min-height: 4.5rem; resize: vertical; font: inherit; color: var(--text);
    border: 1px solid var(--border); background: var(--surface);
    border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3);
  }
  .mine-count { font-size: var(--text-xs); color: var(--text-faint); font-variant-numeric: tabular-nums; text-align: end; }
}
