:root { color-scheme:light; font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif; color:#222f32; background:#f6f6f1; }
* { box-sizing:border-box; }
body { margin:0; min-height:100vh; }
h1,h2,p { margin:0; }
button,select,input,summary,a { font:inherit; color:inherit; }
button,summary,.bar a { cursor:pointer; display:inline-flex; align-items:center; justify-content:center; min-height:40px; padding:0 .9rem; border:1px solid #ccd1c8; border-radius:6px; background:#fff; text-decoration:none; }
button:disabled { opacity:.48; cursor:default; }
[hidden] { display:none !important; }
:focus-visible { outline:2px solid #187c66; outline-offset:2px; }
.top,.brand,.tools,.bar,.foot,.result,.pager,.views { display:flex; align-items:center; gap:12px; }
.top { padding:12px max(4%,env(safe-area-inset-right)) 12px max(4%,env(safe-area-inset-left)); border-bottom:1px solid #d9dcd3; justify-content:space-between; }
.brand { flex-wrap:wrap; gap:10px; }
.brand a { color:#4a6058; text-underline-offset:3px; }
.brand span { color:#9ca79d; }
h1 { font-size:1.16rem; letter-spacing:-.035em; }
h2,.bar label { font-size:1rem; font-weight:650; }
.run { background:#245641; color:white; border-color:#245641; font-weight:600; }
button:not(:disabled):hover,summary:hover,.bar a:hover { filter:brightness(.95); }
#menu { position:relative; }
summary { list-style:none; }
summary::-webkit-details-marker { display:none; }
.menu { position:absolute; z-index:3; top:calc(100% + 6px); right:0; width:10rem; padding:5px; background:#fff; border:1px solid #ccd1c8; border-radius:8px; box-shadow:0 8px 24px #18352a1c; }
.menu button { display:block; border:0; text-align:left; width:100%; }
main { margin:20px auto; width:94%; max-width:1720px; }
.panels { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.05fr); gap:12px; }
.panel { min-width:0; height:calc(100vh - 206px); height:max(350px,calc(100dvh - 206px)); display:grid; grid-template-rows:auto minmax(0,1fr) auto; overflow:hidden; border:1px solid #ccd2c7; border-radius:9px; background:#fff; }
.bar,.foot,.pager,.result { min-width:0; justify-content:space-between; }
.bar { min-height:52px; padding:5px 14px; border-bottom:1px solid #d9ded4; }
.bar select { max-width:67%; min-height:38px; min-width:0; border:0; background:#f1f4ef; border-radius:4px; padding:0 8px; }
.bar a { min-height:34px; border:0; background:#e9f0e8; color:#254d3c; font-size:.875rem; }
textarea { width:100%; height:100%; margin:0; resize:none; border:0; border-radius:0; outline-offset:-2px!important; background:#fdfefb; color:#273944; padding:20px; font:1rem/1.65 ui-monospace,SFMono-Regular,Consolas,monospace; tab-size:2; overflow:auto; }
#attachment { padding:20px; align-self:center; text-align:center; }
.foot,.pager { border-top:1px solid #d9ded4; min-height:44px; padding:3px 12px; font-size:.875rem; color:#4c5f55; }
#paper { min-width:0; overflow:auto; padding:clamp(9px,1.5vw,24px); background:#e4e8df; }
#paper canvas { display:block; width:100%; height:auto; background:white; box-shadow:0 3px 12px #26382225; }
#empty { margin:24px auto; text-align:center; color:#45564b; }
.pager { justify-content:center; }
.pager button,.result button { min-height:36px; border:0; background:transparent; font-size:.875rem; }
.result { margin:8px 0; gap:8px; font-size:.875rem; color:#42574c; }
.result button { flex:none; text-decoration:underline; text-underline-offset:3px; }
#log { white-space:pre-wrap; overflow-wrap:anywhere; max-height:36vh; overflow:auto; line-height:1.5; background:#202a27; color:#f0f5ee; padding:14px; border-radius:6px; }
.views { display:none; }
dialog { width:min(90%,360px); border:1px solid #ccd2c7; border-radius:10px; padding:20px; }
dialog form { display:grid; gap:12px; }
dialog input { min-width:0; padding:10px; }
dialog form div { display:flex; justify-content:flex-end; gap:8px; }
#file-error { color:#9b392c; }
@media(max-width:820px), (max-width:960px) and (max-height:540px) {
  .top { flex-wrap:wrap; gap:8px; padding:8px 4%; }
  .tools { gap:6px; } .tools button,.tools summary { min-height:44px; }
  .brand { gap:7px; } .brand a { font-size:.875rem; } h1 { font-size:1rem; }
  main { width:94%; margin:10px auto; }
  .views { display:flex; gap:0; margin-bottom:8px; }
  .views button { flex:1; border-radius:0; min-height:44px; background:#fbfcf9; }
  .views button:first-child { border-radius:6px 0 0 6px; } .views button:last-child { border-radius:0 6px 6px 0; border-left:none; }
  .views button[aria-pressed=true] { background:#e2ece1; color:#234832; font-weight:650; }
  .panels { display:block; }
  main[data-view=source] .output,main[data-view=pdf] .source { display:none; }
  .panel { height:max(245px,calc(100dvh - 251px)); }
  .bar { min-height:47px; } textarea { padding:13px; }
  .pager button,.result button,.bar a { min-height:44px; }
}
@media(max-width:365px) { .top { align-items:flex-start; } .brand { min-height:40px; } .top .tools { margin-left:auto; } }
#code { min-height:0; height:100%; }
.cm-editor { height:100%; background:#fdfefb; font-size:1rem; }
.cm-editor .cm-scroller { overflow:auto; font-family:ui-monospace,SFMono-Regular,Consolas,monospace; line-height:1.65; }
.cm-editor .cm-gutters { background:#f4f6f0; color:#687767; border:0; }
.cm-editor .cm-content { padding:14px 4px; min-width:0; }
.cm-editor.cm-focused { outline:2px solid #417858; outline-offset:-2px; }
.pager select { min-width:0; max-width:40%; border:0; background:transparent; font-size:.875rem; }
@media(max-width:420px) { .pager { gap:3px; padding-inline:4px; } .pager button { padding-inline:6px; } }


.project-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 18rem) auto;
  justify-content: start;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.project-bar label { font-size: .875rem; font-weight: 650; }
.project-bar select {
  width: 100%; min-width: 0; min-height: 44px; padding: 0 8px;
  border: 1px solid #ccd1c8; border-radius: 6px; background: #fff;
}
.project-bar button { min-height: 44px; white-space: nowrap; }
#project-error { color: #9b392c; }
@media (max-width:820px), (max-width:960px) and (max-height:540px) {
  .project-bar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; }
  .project-bar button { padding-inline: 8px; }
}
