:root {
  color-scheme: light dark;
  --bg: #f1f5f9; --surface: #fff; --text: #0f172a; --muted: #475569;
  --border: #cbd5e1; --accent: #0369a1; --soft: #e0f2fe;
  --notice: #fff4dd; --notice-edge: #a16207;
  font: 16px/1.6 system-ui, sans-serif; color: var(--text); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
main, section, header > * { min-width: 0; }
.workspace-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px clamp(16px, 1.5vw, 40px) 0; border-bottom: 1px solid var(--border); background: var(--surface); }
.workspace-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-size: 1.15rem; font-weight: 800; text-decoration: none; }
.workspace-brand img { flex: 0 0 32px; }
.workspace-context { font-size: .85rem; color: var(--muted); }
.workspace-nav { display: flex; flex-wrap: wrap; flex-basis: 100%; gap: 4px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.workspace-nav a { display: inline-flex; align-items: center; flex: 0 0 auto; min-height: 44px;
  padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: .875rem; font-weight: 600; }
.workspace-nav a:hover, .workspace-nav a[aria-current=page] { color: var(--accent); background: var(--soft); }
main { width: 100%; margin: 24px auto; padding: 0 clamp(16px, 1.5vw, 40px) 40px; }
h1 { font-size: clamp(1.65rem, 2.4vw, 2.15rem); line-height: 1.2; margin: 0 0 12px; }
h2 { font-size: 1.15rem; line-height: 1.4; margin: 0 0 12px; }
h3 { font-size: 1rem; }
h1, h2, p, li, pre, #result { overflow-wrap: anywhere; }
.lead { font-size: 1rem; color: var(--muted); }
section { background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 24px; margin: 20px 0; box-shadow: 0 3px 12px rgb(15 23 42 / 4%); }
aside { padding: 14px 16px; background: var(--notice); border-left: 4px solid var(--notice-edge); border-radius: 6px; }
label { display: block; margin-top: 16px; font-weight: 600; font-size: .9rem; }
input[type=url], input[type=password], input[type=text], input[type=file], textarea, select {
  display: block; width: 100%; max-width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
input[type=file] { padding: 8px; }
input[type=file]::file-selector-button { min-height: 36px; margin-right: 8px; }
textarea { resize: vertical; }
.check, label:has(> input[type=checkbox]) { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; }
input[type=checkbox] { flex: 0 0 20px; width: 20px; height: 20px; margin: 3px 0 0; }
button { font: inherit; min-height: 44px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--action-bg, #0369a1);
  background: var(--action-bg, #0369a1); color: var(--action-fg, #fff); cursor: pointer; margin: 12px 6px 0 0; max-width: 100%; white-space: normal; }
button:disabled { opacity: .5; cursor: default; }
button#disconnect, button#clear { background: var(--surface); color: var(--accent); }
pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); padding: 16px; border-radius: 8px; font-size: .85rem; }
a { color: var(--accent); }
li { margin: 8px 0; }
summary { cursor: pointer; min-height: 44px; padding-block: 10px; }
.setup-guide { padding: 2px 12px; border: 1px solid var(--border); border-radius: 8px; margin-block: 16px; }
#status { font-weight: 600; padding: 10px 12px; border-radius: 8px; background: var(--bg); font-size: .9rem; }
#result { min-height: 48px; }
.actions { display: flex; flex-wrap: wrap; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 3px; }
.skip-link { position: absolute; left: 16px; top: -80px; z-index: 10; padding: 10px 16px; background: var(--surface); }
.skip-link:focus { top: 10px; }
[hidden] { display: none !important; }
.provider-choices { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin-top: 16px; }
.provider-choices button { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin: 0; padding: 12px; text-align: left; background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.provider-choices button span { font-size: .85rem; color: var(--muted); }
.provider-choices button[aria-pressed=true] { border: 2px solid var(--accent); padding: 11px; background: var(--soft); }
#connection-summary { color: var(--muted); font-size: .9rem; }
.setup-button { display: inline-flex; min-height: 44px; align-items: center; padding: 10px 14px; border-radius: 8px; background: var(--accent); color: var(--surface); font-weight: 600; text-decoration: none; }
@media(max-width:360px) { .provider-choices { grid-template-columns: minmax(0,1fr); } }
@media (min-width: 1100px) {
  main { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
  main > :not(section) { grid-column: 1 / -1; margin-block: 0; }
  main > section { margin: 0; }
  main > section:last-of-type, .review-results, #session-privacy { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .workspace-nav { flex-wrap: nowrap; }
}
@media (max-width: 520px) {
  .workspace-context { flex-basis: 100%; }
  section { padding: 16px; }
  input[type=file] { font-size: 1rem; }
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1220; --surface: #111a2e; --text: #e2e8f0; --muted: #b4c1d2;
    --border: #334155; --accent: #7dd3fc; --soft: #153449; --notice: #382c14; --notice-edge: #fbbf24; }
  button { background: #0369a1; border-color: #0369a1; }
}
.review-source #report-file { border: 2px dashed var(--accent); background: var(--soft); padding: 12px; }
.review-source #report-file::file-selector-button { border: 1px solid var(--accent); border-radius: 6px; padding: 8px 12px; background: var(--surface); color: var(--text); }
#study-workflow [data-nav-language=ko] { display: none; }
html[lang^=ko] #study-workflow [data-nav-language=en] { display: none; }
html[lang^=ko] #study-workflow [data-nav-language=ko] { display: inline; }
