:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  --ink: #17202a;
  --muted: #627078;
  --line: #d7dde0;
  --paper: #ffffff;
  --desk: #eef2f3;
  --blue: #166a8f;
  --green: #14764b;
  --amber: #ad6500;
  --red: #a93226;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--desk); }
header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.5rem; background: var(--paper); border-bottom: 1px solid var(--line); }
h1, h2, p { margin: 0; }
h1 { font-size: 1.25rem; letter-spacing: -.02em; }
.subtitle { margin-top: .2rem; color: var(--muted); font-size: .82rem; }
.provider-badge { padding: .4rem .65rem; color: var(--green); background: #e7f5ed; border: 1px solid #a8d5ba; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.provider-badge.offline { color: var(--red); background: #fdedec; border-color: #edb9b5; }
main { padding: 1rem; }
.connection-alert { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .8rem; margin-bottom: 1rem; padding: .8rem 1rem; color: #772b23; background: #fff0ee; border: 1px solid #e6a9a2; border-left: 5px solid var(--red); border-radius: 5px; }
.connection-alert[hidden] { display: none; }
.connection-alert a { color: white; background: var(--red); padding: .45rem .7rem; border-radius: 4px; text-decoration: none; font-weight: 700; white-space: nowrap; }
.mock-alert { display: grid; grid-template-columns: auto 1fr; gap: .8rem; margin-bottom: 1rem; padding: .8rem 1rem; color: #6d4400; background: #fff8e8; border: 1px solid #e3c47d; border-left: 5px solid var(--amber); border-radius: 5px; }
.mock-alert[hidden] { display: none; }
.mock-alert code { padding: .08rem .25rem; color: #573700; background: #f5e4b9; border-radius: 3px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; min-height: 70vh; }
.panel, .history { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
#drop-zone { display: grid; place-items: center; gap: .35rem; min-height: 120px; padding: 1rem; text-align: center; cursor: pointer; border-bottom: 1px dashed #9eabb0; transition: background .15s, box-shadow .15s; }
#drop-zone:hover, #drop-zone.dragging { background: #eaf5f9; box-shadow: inset 0 0 0 2px #7db5ca; }
#drop-zone.disabled { opacity: .55; pointer-events: none; }
#file-input { display: none; }
.drop-icon { display: grid; place-items: center; width: 34px; height: 34px; color: var(--blue); background: #dceef5; border-radius: 50%; font-size: 1.45rem; font-weight: 700; }
.file-action { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 66px; padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
.file-action div { display: grid; gap: .15rem; min-width: 0; }
.file-action strong, .file-action small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-action small { color: var(--muted); }
button { padding: .48rem .75rem; border: 1px solid #aab7b8; border-radius: 4px; background: white; cursor: pointer; }
button:focus-visible, a:focus-visible, #drop-zone:focus-within { outline: 3px solid #72b7d2; outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .45; }
.primary-button { min-width: 96px; color: white; background: var(--blue); border-color: var(--blue); font-weight: 750; }
.preview { display: grid; place-items: center; height: calc(70vh - 188px); padding: 1rem; overflow: auto; }
.preview.empty { color: var(--muted); }
.preview img, .preview embed { max-width: 100%; width: 100%; height: 100%; object-fit: contain; }
.result-panel { display: flex; flex-direction: column; }
.work-status { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .75rem; min-height: 66px; padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
.work-status > div { display: grid; gap: .1rem; }
.work-status span:not(.status-indicator) { color: var(--muted); font-size: .82rem; }
.work-status time { min-width: 58px; color: var(--muted); font: 700 .9rem ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; }
.status-indicator { width: 13px; height: 13px; background: #aab4b8; border-radius: 50%; }
.work-status.ready .status-indicator { background: var(--blue); }
.work-status.processing { background: #fff8e8; }
.work-status.processing .status-indicator { background: transparent; border: 3px solid #f0c36b; border-top-color: var(--amber); animation: spin .75s linear infinite; }
.work-status.success { background: #ebf7f0; }
.work-status.success .status-indicator { background: var(--green); box-shadow: 0 0 0 4px #c9ead7; }
.work-status.mock { background: #fff8e8; }
.work-status.mock .status-indicator { background: var(--amber); box-shadow: 0 0 0 4px #f4dfad; }
.work-status.failed, .work-status.blocked { background: #fdedec; }
.work-status.failed .status-indicator, .work-status.blocked .status-indicator { background: var(--red); box-shadow: 0 0 0 4px #f5ceca; }
@keyframes spin { to { transform: rotate(360deg); } }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); }
.metrics span { padding: .7rem; background: #fdfefe; text-align: center; }
.toolbar { display: flex; justify-content: space-between; padding: .5rem; border-block: 1px solid var(--line); }
.tab.active { color: white; background: var(--blue); border-color: var(--blue); }
.pane { display: none; flex: 1; min-height: 0; margin: 0; padding: 1rem; overflow: auto; white-space: pre-wrap; line-height: 1.55; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pane.active { display: block; }
.pane.failed { color: var(--red); background: #fdedec; }
.tables { font-family: inherit; white-space: normal; }
.tables table { width: 100%; margin-bottom: 1rem; border-collapse: collapse; }
.tables th, .tables td { padding: .45rem; border: 1px solid #99a3a4; text-align: left; }
.history { margin-top: 1rem; padding: 1rem; }
.history h2 { margin-bottom: .7rem; font-size: 1rem; }
.history-row { display: grid; grid-template-columns: 1fr auto auto; gap: 1rem; width: 100%; margin-bottom: .35rem; text-align: left; }
.status-ok { color: var(--green); }
.status-failed { color: var(--red); }
@media (prefers-reduced-motion: reduce) { .work-status.processing .status-indicator { animation: none; } }
@media (max-width: 850px) {
  .workspace { grid-template-columns: 1fr; }
  .preview { height: 45vh; }
  .connection-alert { grid-template-columns: 1fr; }
  .mock-alert { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}
