:root {
  --bg: var(--tg-theme-bg-color, #12141a);
  --sec-bg: var(--tg-theme-secondary-bg-color, #1c2029);
  --text: var(--tg-theme-text-color, #f1f5f9);
  --hint: var(--tg-theme-hint-color, #94a3b8);
  --btn: var(--tg-theme-button-color, #3b82f6);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --border: rgba(148, 163, 184, 0.18);
  --ok: #22c55e;
  interpolate-size: allow-keywords;
}
* { box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { margin: 0; padding: clamp(12px, 3vw, 20px); background: var(--bg); color: var(--text); max-width: 780px; margin-inline: auto; }
.header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.title { margin: 0; font-size: clamp(1.05rem, 2.5vw, 1.25rem); font-weight: 700; }
.subtitle { margin: 2px 0 0; font-size: 12px; color: var(--hint); }
.badge { font-size: 12px; padding: 5px 10px; border-radius: 999px; background: var(--sec-bg); border: 1px solid var(--border); white-space: nowrap; }
.tabs { position: relative; display: flex; gap: 6px; padding: 4px; background: var(--sec-bg); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 14px; }
.tab { position: relative; z-index: 1; flex: 1; padding: 9px 8px; border: none; border-radius: 9px; background: transparent; color: var(--hint); font-weight: 600; font-size: 13px; cursor: pointer; transition: color 0.2s ease; }
.tab.active { color: var(--btn-text); anchor-name: --active-tab; }
.tab-indicator { position: absolute; position-anchor: --active-tab; inset: anchor(top) anchor(right) anchor(bottom) anchor(left); background: var(--btn); border-radius: 9px; z-index: 0; transition: inset 0.24s cubic-bezier(0.22, 1, 0.36, 1); }
.workspace { container-type: inline-size; }
.card { background: var(--sec-bg); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
label { display: block; font-size: 12px; color: var(--hint); font-weight: 600; margin-bottom: 5px; }
.label-row label { margin-bottom: 0; }
.help-pill { anchor-name: --help-btn; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg); color: var(--hint); font-size: 12px; font-weight: 700; cursor: pointer; }
.popover-box { position-anchor: --help-btn; inset: auto; top: calc(anchor(bottom) + 6px); right: anchor(right); max-width: min(320px, 88vw); margin: 0; padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 12.5px; line-height: 1.45; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45); }
.popover-box p { margin: 6px 0 0; color: var(--hint); }
input, select, textarea { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px; font-size: 14px; margin-bottom: 12px; }
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
.btn { width: 100%; padding: 12px; border: none; border-radius: 10px; background: var(--btn); color: var(--btn-text); font-size: 14px; font-weight: 700; cursor: pointer; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.mini-btn { padding: 7px 11px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn-row { display: flex; gap: 6px; }
.hidden { display: none !important; }
.mono-title { font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.code-view { white-space: pre-wrap; word-break: break-word; background: var(--bg); padding: 12px; border-radius: 10px; border: 1px solid var(--border); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.45; max-height: 50vh; overflow-y: auto; margin: 0; }
.doc-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); gap: 10px; }
.doc-item:last-child { border-bottom: none; }
.doc-name { font-size: 13px; font-weight: 600; word-break: break-all; }
.doc-meta { font-size: 11px; color: var(--hint); margin-top: 2px; }
.stat-row { display: flex; justify-content: space-between; font-size: 13px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.stat-row:last-child { border-bottom: none; }
.accordion { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.accordion summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--hint); user-select: none; }
.accordion::details-content { transition: height 0.25s ease, opacity 0.25s ease, content-visibility 0.25s allow-discrete; height: 0; opacity: 0; overflow: clip; }
.accordion[open]::details-content { height: auto; opacity: 1; }
.mode-grid { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 10px; }
@container (min-width: 340px) { .mode-grid { grid-template-columns: 1fr 1fr; } .span-full { grid-column: span 2; } }
.doc-dialog { width: min(94vw, 760px); max-height: 88vh; padding: 0; border: 1px solid var(--border); border-radius: 16px; background: var(--sec-bg); color: var(--text); opacity: 0; transform: translateY(14px) scale(0.98); transition: opacity 0.22s ease, transform 0.22s ease, overlay 0.22s allow-discrete, display 0.22s allow-discrete; }
.doc-dialog[open] { opacity: 1; transform: translateY(0) scale(1); }
@starting-style { .doc-dialog[open] { opacity: 0; transform: translateY(14px) scale(0.98); } }
.doc-dialog::backdrop { background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(3px); }
.dialog-shell { display: flex; flex-direction: column; padding: 14px; max-height: 88vh; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.dialog-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.dialog-pre { max-height: 66vh; flex: 1; }
.refine-accordion { margin-bottom: 10px; }
.refine-summary { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; text-align: center; list-style: none; user-select: none; }
.refine-summary::-webkit-details-marker { display: none; }
.refine-body { margin-top: 10px; }
.refine-label { display: block; margin-bottom: 8px; font-size: 12px; color: var(--hint); font-weight: 600; }
.refine-textarea { width: 100%; min-height: 80px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font-family: inherit; font-size: 14px; resize: vertical; margin-bottom: 10px; }
.refine-btn { margin-top: 0; }
