/* POLYGONUM Tools */
:root {
  color-scheme: dark;
  --ground: #181818;
  --field: radial-gradient(ellipse at 22% 5%, #262626 0, #1a1a1a 47%, #101010 100%);
  --surface: #191919;
  --raised: #262626;
  --ink: #ededed;
  --muted: #929292;
  --rule: #3d3d3d;
  --control-line: #797873;
  --highlight: #ffffff;
  accent-color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-height: 100vh; margin: 0; background: var(--ground) var(--field) no-repeat; color: var(--ink); font-size: 15px; }
.workspace { max-width: 1180px; margin: 0 auto; padding: 0 36px 48px; }
.masthead {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  min-height: 66px; border-bottom: 1px solid var(--rule);
}
.brand { font-size: 14px; font-weight: 750; letter-spacing: .06em; }
.brand span { font-size: 9px; vertical-align: text-top; }
.system-state { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 12px; color: var(--muted); }
.system-state span::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 7px 2px 0; border-radius: 50%; background: transparent; border: 1px solid var(--muted); }
.system-state .ready::before { background: var(--highlight); border-color: var(--highlight); }
.page-title { padding: 35px 0 26px; }
.page-title h1 { margin: 0; font-size: clamp(23px, 4vw, 46px); font-weight: 400; line-height: 1.08; letter-spacing: .04em; }
.page-title p { margin: 10px 0 0; color: var(--muted); }
.layout { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 18px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--rule); padding: 24px; min-width: 0; }
.panel h2 { font-size: 20px; font-weight: 680; letter-spacing: -.035em; margin: 0 0 22px; }
label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 630; }
textarea, input, select, button { font: inherit; color: inherit; }
select, textarea, input:not([type=file]) { width: 100%; border: 1px solid var(--control-line); background: var(--surface); border-radius: 0; padding: 10px 11px; }
textarea { resize: vertical; margin: 0 0 20px; line-height: 1.45; }
input[type=file] { max-width: 100%; border: 1px dashed var(--control-line); background: var(--surface); padding: 10px; }
input::file-selector-button { color: var(--ink); background: var(--raised); border: 1px solid var(--control-line); padding: 7px 10px; margin-right: 9px; cursor: pointer; }
.hint, figcaption { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 8px 0 0; }
figure { padding: 10px; margin: 14px 0 0; background: var(--raised); }
figure img { max-height: 155px; max-width: 100%; display: block; margin: 0 auto; object-fit: contain; }
figcaption { overflow-wrap: anywhere; }
.type-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 14px; }
.examples, .actions, .downloads { display: flex; flex-wrap: wrap; gap: 8px; }
.examples { gap: 6px; }
.actions { margin-top: 18px; }
.parameter-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
button { cursor: pointer; padding: 9px 13px; min-height: 39px; border: 1px solid var(--control-line); border-radius: 0; background: var(--surface); text-align: left; }
button:hover:not(:disabled) { background: var(--raised); color: var(--highlight); }
button.primary { background: var(--ink); color: var(--ground); }
button.primary:hover:not(:disabled) { background: var(--highlight); color: var(--ground); }
button.quiet { border-color: var(--control-line); font-size: 12px; min-height: 36px; }
:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }
.schematic { border: 1px solid var(--rule); background: var(--surface); margin-top: 17px; padding: 12px 12px 0; }
.schematic-label { color: var(--muted); font-size: 12px; font-weight: 620; }
canvas { width: 100%; height: 156px; display: block; }
.notice { color: var(--muted); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; margin: 10px 0 0; }
.notice:empty { display: none; }
.notice.error, .warnings { color: var(--ink); }
.warnings { margin: 12px 0 0; padding-left: 17px; font-size: 13px; }
.result { margin-top: 20px; padding-top: 13px; border-top: 1px solid var(--rule); }
.result h3 { margin: 0; font-size: 16px; }
.downloads { margin-top: 12px; }
.downloads a { color: var(--ink); border: 1px solid var(--control-line); padding: 6px 10px; text-decoration: none; font-size: 13px; }
.downloads a:hover { background: var(--raised); color: var(--highlight); }
@media (max-width: 810px) {
  .layout { grid-template-columns: 1fr; }
  .workspace { max-width: 650px; padding: 0 20px 32px; }
}
@media (max-width: 450px) {
  .masthead { align-items: flex-start; flex-direction: column; justify-content: center; gap: 6px; }
  .panel { padding: 16px; }
  .type-row { grid-template-columns: 1fr; gap: 8px; }
}

.access-panel { border: 1px solid var(--control-line); padding: 20px; background: var(--surface); margin-bottom: 20px; }
.access-panel h2 { margin: 0 0 16px; font-size: 18px; }
.access-row { display: flex; gap: 10px; max-width: 640px; }
.access-row input { min-width: 0; }
.access-row button { flex-shrink: 0; }
#pdf-controls { margin-top: 16px; max-width: 260px; }
.notice.error { font-weight: 650; }
@media (max-width:450px) { .access-row { flex-direction: column; } }

::placeholder { color: var(--muted); opacity: 1; }
::selection { color: var(--ground); background: var(--ink); }
button.primary { border-color: var(--ink); }
button:disabled { cursor: default; color: var(--muted); border-color: var(--rule); background: var(--surface); }
input[type=file]::file-selector-button:hover { color: var(--highlight); }
.notice.error:not(:empty), .warnings:not([hidden]) { border-inline-start: 2px solid var(--ink); padding-inline-start: 10px; }
