:root {
  --ink: #17233d;
  --muted: #68738a;
  --blue: #1d3f91;
  --blue-2: #2f6fec;
  --paper: #fbfcff;
  --line: #dfe5ee;
  --warm: #f6efe4;
  --card: rgba(255,255,255,.94);
  font-family: "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, sans-serif;
  color: var(--ink);
  background: #e9eef6;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: clip; }
button, input { font: inherit; }
button { color: inherit; }
body {
  background:
    radial-gradient(circle at 5% 5%, rgba(244,177,83,.2), transparent 27rem),
    radial-gradient(circle at 95% 95%, rgba(47,111,236,.13), transparent 35rem),
    linear-gradient(145deg,#f6f2ea 0%,#eef3f9 48%,#e4ebf5 100%);
}
button { border: 0; cursor: pointer; }
.app-shell { height: 100dvh; min-height: 0; display: grid; grid-template-rows: 76px minmax(0,1fr); }
.topbar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 28px; background: rgba(255,255,255,.84); border-bottom: 1px solid rgba(30,57,104,.1);
  box-shadow: 0 3px 24px rgba(33,49,78,.06); backdrop-filter: blur(18px); z-index: 5;
}
.brand-lockup { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 46px; height: 46px; flex-shrink: 0; border-radius: 12px;
  background: #1d3f91;
}
.brand-mark img { display: block; width: 100%; height: 100%; }
.brand-lockup strong { display: block; font-size: 17px; letter-spacing: -.2px; }
.brand-lockup span { display: block; color: #375687; font-size: 12px; font-weight: 600; letter-spacing: .7px; margin-top: 1px; }
.page-title { text-align: center; line-height: 1; }
.page-kicker { font-size: 10px; color: var(--blue-2); font-weight: 700; letter-spacing: .8px; }
.page-title h1 { font-size: 19px; margin: 7px 0 0; letter-spacing: 2px; }
.top-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.language-badge { padding: 7px 12px; border-radius: 20px; background: #eaf0fb; color: #34558f; font-size: 11px; font-weight: 600; }
.cloud-account-button { padding: 9px 12px; border: 1px solid #b7c9e3; border-radius: 10px; color: #254b87; background: #edf3ff; font-size: 13px; font-weight: 600; }
.cloud-account-button[data-connected="true"] { border-color: #7eae9c; }
#cloudAccountDialog { width: min(480px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); overflow-y: auto; }
#cloudAccountDialog [hidden] { display: none; }
.cloud-connection-info { padding: 12px; background: #f0f4fa; border-radius: 10px; margin-bottom: 16px; }
.cloud-connection-info p { margin: 0 0 6px; font-size: 13px; line-height: 1.6; }
.cloud-connection-info p:first-child { font-weight: 600; }
#cloudCheckButton, #cloudSignOut { padding: 8px 12px; border: 1px solid #cbd6e7; border-radius: 8px; background: white; color: #254b87; font-size: 13px; }
#cloudAuthForm { display: grid; gap: 8px; }
#cloudAuthForm label { font-size: 14px; font-weight: 600; }
#cloudAuthForm input { min-width: 0; width: 100%; min-height: 44px; padding: 9px 10px; border: 1px solid #b7c9e3; border-radius: 8px; font-size: 16px; }
.cloud-auth-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.cloud-auth-actions button { flex: 1; padding: 11px; border-radius: 8px; background: #edf3ff; color: #254b87; font-size: 14px; font-weight: 600; }
.cloud-auth-actions #cloudSignIn { color: white; background: #1d3f91; }
.cloud-auth-message { font-size: 14px; line-height: 1.6; color: #17634e; }
.cloud-auth-message[data-error="true"] { color: #a32d2d; }
.cloud-note { margin: 8px 0 0; font-size: 12px; color: #52627a; line-height: 1.7; }
#cloudUserEmail { overflow-wrap: anywhere; }
#libraryButton { background: #edf3ff; color: #254b87; border: 1px solid #d2def2; }
#libraryDialog { width: min(760px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); overflow-y: auto; }
#libraryDialog [hidden] { display: none; }
#libraryGate { margin-top: 18px; padding: 16px; border-radius: 10px; background: #f0f4fa; font-size: 14px; line-height: 1.6; }
.library-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 14px; }
.library-actions button, #librarySignIn { padding: 10px 12px; border-radius: 8px; background: #edf3ff; color: #254b87; font-size: 14px; font-weight: 600; }
.library-actions #libraryUpload { background: #1d3f91; color: white; }
.library-search-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
#librarySearch { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid #b7c9e3; border-radius: 8px; font-size: 15px; }
.library-list { margin-top: 14px; }
.library-file { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid #dce4ef; }
.library-file strong { display: block; overflow-wrap: anywhere; font-size: 14px; color: #193c71; }
.library-file small { display: block; margin-top: 4px; font-size: 12px; color: #52627a; }
.library-file-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.library-file-actions button { min-height: 38px; padding: 8px 10px; border-radius: 8px; background: #edf3ff; color: #254b87; font-size: 13px; }
#libraryMessage[data-error="true"] { color: #a32d2d; }
@media (max-width: 620px) { .library-file { grid-template-columns: 1fr; } }
@media (max-width: 620px) { .language-badge { display: none; } .cloud-account-button { padding: 8px; font-size: 12px; } }
button:focus-visible, input:focus-visible { outline: 3px solid #82a9ee; outline-offset: 3px; }
.board-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 2px 12px; }
.history-actions { display: flex; gap: 6px; }
.history-actions button { display: flex; gap: 7px; align-items: center; min-height: 40px; padding: 8px 13px; border: 1px solid #d4deec; border-radius: 10px; background: #f4f7fc; color: #254b87; font-size: 12px; font-weight: 600; transition: background .15s; }
.history-actions button:not(:disabled):hover { background: #e5eeff; border-color: #91b0e8; }
.history-actions button:not(:disabled):active { transform: translateY(1px); }
.history-actions button span { font-size: 20px; line-height: 1; }
.history-status { font-size: 11px; color: #64748b; font-variant-numeric: tabular-nums; }
.import-board-btn { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 13px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.import-board-btn span { font-size: 19px; line-height: 1; }
.import-board-btn:not(:disabled):hover { filter: brightness(.96); }
.capture-board-btn { background: #1d3f91; color: white; border: 1px solid #1d3f91; }
.capture-board-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.import-status { flex-basis: 100%; margin: 0; color: #65748a; font-size: 11px; line-height: 1.5; }
.icon-btn, .lang {
  width: 37px; height: 37px; border: 1px solid #dce2eb; background: #fff; border-radius: 50%; font-weight: 700;
  box-shadow: 0 3px 9px rgba(41,55,82,.06);
}
.lang { height: 31px; width: 42px; border-radius: 18px; font-size: 11px; }
.lang.active { background: var(--blue); border-color: var(--blue); color: white; }

.workspace {
  min-height: 0; display: grid; grid-template-columns: minmax(0,1fr) 380px; gap: 14px;
  padding: 14px;
}
.canvas-card, .tool-rail {
  min-height: 0; border-radius: 22px; background: var(--card); border: 1px solid rgba(255,255,255,.9);
  box-shadow: 0 16px 45px rgba(38,56,88,.09), inset 0 0 0 1px rgba(39,66,116,.04);
}
.canvas-card { display: grid; grid-template-rows: auto auto minmax(0,1fr) auto; overflow: hidden; padding: 15px; }
.canvas-heading { display: flex; justify-content: space-between; align-items: center; padding: 0 4px 12px; }
.eyebrow { margin: 0 0 2px; font-size: 9px; text-transform: uppercase; letter-spacing: 1.3px; font-weight: 700; color: #b57a28; }
.canvas-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.3px; }
.canvas-heading p:not(.eyebrow) { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.canvas-status { display: flex; gap: 7px; align-items: center; padding: 7px 10px; border-radius: 20px; background: #eff8f2; color: #24784f; font-size: 10px; font-weight: 600; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #31aa73; box-shadow: 0 0 0 4px rgba(49,170,115,.14); }

.board-wrap {
  position: relative; min-height: 300px; overflow: hidden; border: 1px solid #cad2df; border-radius: 18px;
  background: #fff; box-shadow: inset 0 2px 8px rgba(50,65,88,.04);
  cursor: crosshair; touch-action: none;
}
#board { width: 100%; height: 100%; display: block; }
.board-hint {
  pointer-events: none; position: absolute; inset: 0; margin: auto; width: max-content; height: max-content;
  display: none; gap: 13px; align-items: center; padding: 13px 18px; border-radius: 17px;
  color: #7a8597; background: rgba(255,255,255,.83); box-shadow: 0 8px 30px rgba(49,66,94,.1);
  border: 1px solid rgba(215,222,232,.8); backdrop-filter: blur(9px); transition: .25s;
}
.board-hint.hidden { opacity: 0; transform: translateY(6px); }
.board-hint > span { color: #d09a45; font-size: 22px; }
.board-hint strong, .board-hint small { display: block; }
.board-hint strong { color: #3a465c; font-size: 12px; }
.board-hint small { font-size: 9px; margin-top: 2px; }
.zoom-controls {
  position: absolute; left: 12px; bottom: 12px; display: flex; align-items: center; overflow: hidden;
  border: 1px solid #dae0e9; border-radius: 11px; background: rgba(255,255,255,.9);
  box-shadow: 0 6px 16px rgba(32,50,80,.1); backdrop-filter: blur(8px);
}
.zoom-controls button, .zoom-controls span { height: 32px; min-width: 32px; display: grid; place-items: center; background: transparent; font-size: 11px; }
.zoom-controls button:hover { background: #eef2f8; }
.zoom-controls span { min-width: 48px; border-inline: 1px solid #e2e6ed; font-weight: 600; color: #566176; }
.zoom-controls #zoomFit { padding: 0 9px; border-left: 1px solid #e2e6ed; color: var(--blue); }
.cursor-tip {
  position: absolute; width: 28px; height: 28px; border-radius: 50%; border: 1px dashed rgba(30,63,145,.75);
  background: rgba(255,255,255,.5); pointer-events: none; opacity: 0; transform: translate(-50%,-50%);
}
.board-footer { height: 37px; display: flex; align-items: end; justify-content: space-between; color: #737f91; font-size: 10px; padding: 0 4px; }
.instruction { display: flex; align-items: center; gap: 6px; }
.mouse-icon { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 6px; background: #edf1f6; color: var(--blue); }
.coord-readout { display: flex; gap: 6px; }
.coord-readout span { background: #f0f3f7; border-radius: 6px; padding: 3px 6px; min-width: 49px; text-align: center; font-variant-numeric: tabular-nums; }

.tool-rail { overflow: hidden; }
.rail-scroll { height: 100%; overflow-y: auto; padding: 12px; scrollbar-width: thin; scrollbar-color: #c8d2e2 transparent; }
.tool-section { border-bottom: 1px solid #e7ebf1; padding: 0 0 12px; margin-bottom: 12px; }
.tool-section:last-child { border-bottom: 0; margin-bottom: 0; }
.section-label { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 7px; }
.section-label span { font-size: 11px; font-weight: 700; color: #46536b; }
.section-label small { font-size: 8px; color: #9aa3b3; }
.section-label.accent span { color: var(--blue-2); }
.segmented { display: grid; padding: 4px; gap: 3px; background: #f0f3f8; border: 1px solid #e1e6ef; border-radius: 13px; }
.segmented.two { grid-template-columns: repeat(2,1fr); }
.segmented.three { grid-template-columns: repeat(3,1fr); }
.segmented button {
  display: flex; align-items: center; justify-content: center; gap: 7px; height: 42px; border-radius: 9px;
  background: transparent; font-size: 10px; font-weight: 600; color: #566177; transition: .18s ease;
}
.segmented button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.segmented button.active { color: white; background: linear-gradient(145deg,#376fe3,#234ead); box-shadow: 0 5px 12px rgba(35,78,173,.28), inset 0 1px rgba(255,255,255,.22); }
.drawing-tools { background: #eefaf9; border-color: #d3efea; }
.drawing-tools button.active { background: white; color: #1a806c; box-shadow: 0 3px 10px rgba(31,105,92,.12); }
.palette { display: flex; align-items: center; justify-content: space-between; padding: 10px 2px 7px; }
.swatch {
  width: 24px; height: 24px; padding: 0; border-radius: 50%; background: var(--swatch);
  border: 3px solid white; box-shadow: 0 0 0 1px #cbd2de, 0 2px 5px rgba(30,40,60,.13); transition: .16s;
}
.swatch.active { box-shadow: 0 0 0 2px var(--blue), 0 3px 8px rgba(30,40,60,.18); transform: scale(1.08); }
.thickness { display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; }
.thickness button { height: 27px; border-radius: 8px; background: #f5f6f9; color: #6f798c; font-size: 9px; font-weight: 600; }
.thickness button.active { color: white; background: var(--blue); }

.instrument-card { border: 1px solid #dfe4ec; border-radius: 13px; margin-bottom: 7px; background: #fff; overflow: hidden; transition: .2s; }
.instrument-card.active { border-color: #a9c0ef; box-shadow: 0 5px 16px rgba(40,76,146,.1); }
.instrument-head { width: 100%; display: flex; align-items: center; padding: 9px 10px; gap: 9px; background: transparent; text-align: left; }
.tool-emoji { width: 25px; height: 25px; display: grid; place-items: center; color: #c78f32; background: #fff6d8; border-radius: 8px; font-size: 16px; font-weight: 700; }
.compass-mini { transform: rotate(-18deg); }
.instrument-name { flex: 1; }
.instrument-name strong, .instrument-name small { display: block; }
.instrument-name strong { font-size: 11px; }
.instrument-name small { color: #8b95a6; font-size: 8px; margin-top: 1px; }
.switch { width: 32px; height: 19px; border-radius: 14px; background: #dfe4eb; position: relative; box-shadow: inset 0 1px 3px rgba(30,40,60,.12); }
.switch::after { content: ""; position: absolute; width: 15px; height: 15px; left: 2px; top: 2px; background: white; border-radius: 50%; box-shadow: 0 1px 4px rgba(20,30,50,.25); transition: .2s; }
.switch.on { background: var(--blue-2); }
.switch.on::after { transform: translateX(13px); }
.instrument-controls { padding: 0 10px 10px; }
.readout-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 6px; margin-bottom: 7px; }
.readout-grid label { display: flex; justify-content: space-between; padding: 6px 7px; background: #f4f6f9; border-radius: 7px; font-size: 8px; color: #758095; }
.readout-grid output { font-weight: 700; color: #39465d; font-variant-numeric: tabular-nums; }
.compass-actions { display: grid; grid-template-columns: .88fr 1.12fr; gap: 6px; }
.center-pin-toggle { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px; margin: 9px 0 7px; padding: 9px 12px; border: 1px solid #b9cbe8; border-radius: 10px; background: #f1f5fb; color: #234982; font-size: 13px; font-weight: 700; touch-action: manipulation; }
.center-pin-toggle span { font-size: 18px; line-height: 1; }
.center-pin-toggle.active { border-color: #315fc5; background: #eaf1ff; color: #173b89; box-shadow: inset 0 0 0 1px rgba(49,95,197,.14); }
.primary-action { width: 100%; border-radius: 9px; padding: 8px 6px; color: white; background: linear-gradient(145deg,#315fc5,#183b8e); font-size: 9px; font-weight: 700; box-shadow: 0 5px 12px rgba(29,63,145,.18); }
.radius-lock { border: 1px solid #d6dce6; border-radius: 9px; background: #f3f5f8; color: #566176; font-size: 9px; font-weight: 700; transition: .18s; }
.radius-lock span { margin-right: 3px; font-size: 13px; }
.radius-lock.active { color: #87550a; border-color: #e2ad48; background: linear-gradient(145deg,#fff6d8,#f5c965); box-shadow: 0 4px 11px rgba(196,132,30,.2); }
.lock-state { display: flex; align-items: center; gap: 5px; margin: 7px 3px 0; color: #8993a4; font-size: 8px; line-height: 1.35; }
.lock-state span { width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: #aab2bf; }
.lock-state.locked { color: #9a6514; font-weight: 600; }
.lock-state.locked span { background: #e2a12c; box-shadow: 0 0 0 3px rgba(226,161,44,.16); }
.center-pin-state { display: flex; align-items: center; justify-content: center; gap: 5px; margin: 0 0 7px; padding: 5px 7px; border: 1px dashed #b9c7df; border-radius: 7px; color: #52627a; background: #f5f8fc; font-size: 11px; }
.center-pin-state span { color: #1d3f91; font-size: 13px; line-height: 1; }
.center-pin-state.pinned { border-style: solid; border-color: #7fa1e2; color: #173b89; background: #eaf1ff; font-weight: 700; box-shadow: inset 0 0 0 1px rgba(255,255,255,.7); }
.primary-action:active { transform: translateY(1px); }
.microcopy { margin: 7px 3px 0; color: #7c8798; font-size: 8px; line-height: 1.45; }
.segmented.drawing-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.adjust-control { margin: 10px 0; }
.compass-size-options { margin-top: 9px; border: 1px solid #dce4ef; border-radius: 8px; background: #f7f9fc; }
.compass-size-options > summary { padding: 8px 10px; color: #34558f; font-size: 11px; font-weight: 600; cursor: pointer; }
.compass-size-options > summary:focus-visible { outline: 3px solid #82a9ee; outline-offset: 2px; border-radius: 8px; }
.compass-size-options[open] > summary { border-bottom: 1px solid #e1e7f0; }
.compass-size-options > .adjust-control { margin: 9px 10px; }
.compass-size-options > .microcopy { margin: 0 10px 10px; }
.adjust-control > label { display: flex; justify-content: space-between; gap: 6px; font-size: 10px; color: #526078; }
.adjust-control output { color: #1d3f91; font-weight: 700; white-space: nowrap; }
.adjust-inputs { display: grid; grid-template-columns: minmax(0, 1fr) 64px; align-items: center; gap: 8px; margin-top: 5px; }
.adjust-inputs input[type="range"] { width: 100%; min-width: 0; accent-color: #2f6fec; }
.adjust-inputs input[type="number"], .point-name-row input { width: 100%; min-width: 0; padding: 6px; border: 1px solid #cbd6e7; border-radius: 7px; background: white; color: #17233d; font-size: 11px; }
.point-editor { margin-top: 12px; }
.point-editor > label { font-size: 10px; color: #526078; }
.point-name-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; margin-top: 5px; }
.point-name-row button { padding: 6px 8px; border-radius: 7px; background: #e8efff; color: #1d3f91; font-size: 10px; }
.point-name-editor { position: absolute; z-index: 3; width: 244px; max-width: calc(100% - 16px); padding: 10px; border: 2px solid #2f6fec; border-radius: 10px; background: white; cursor: default; touch-action: auto; }
.point-name-editor[hidden] { display: none; }
.point-name-editor > label { font-size: 13px; font-weight: 600; color: #193c71; }
.point-name-editor .point-name-row { grid-template-columns: minmax(0, 1fr) auto auto; }
.point-name-editor p { margin: 6px 0 0; color: #52627a; font-size: 12px; line-height: 1.5; }
button:disabled, input:disabled { opacity: .45; cursor: default; }
[data-instrument="ruler"] .tool-emoji { color: #2369b7; background: #e6f2ff; }
.ruler-controls { border-top: 1px solid #e5edf7; padding-top: 9px; }
.ruler-control-row { display: block; margin-bottom: 8px; }
.ruler-control-row > span { display: flex; justify-content: space-between; margin-bottom: 3px; color: #68758b; font-size: 8px; }
.ruler-control-row output { color: #1d5598; font-weight: 700; font-variant-numeric: tabular-nums; }
.ruler-control-row input { width: 100%; height: 4px; accent-color: #2f7dca; cursor: pointer; }
.ruler-preset-row, .ruler-edge-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 7px; }
.ruler-preset-row button, .ruler-edge-actions button { min-height: 29px; border-radius: 8px; border: 1px solid #cfe0f3; color: #285e98; background: #edf6ff; font-size: 8px; font-weight: 700; }
.ruler-preset-row button:hover, .ruler-edge-actions button:hover { background: #dceeff; border-color: #8eb9e8; }
.ruler-edge-actions button { color: white; border-color: #2e78c4; background: linear-gradient(145deg,#4595e4,#2369b7); box-shadow: 0 4px 10px rgba(35,105,183,.16); }
.ruler-edge-actions button:active { transform: translateY(1px); }
[data-instrument="ruler"].active { border-color: #89b9e8; box-shadow: 0 5px 16px rgba(38,111,184,.12); }
[data-instrument="ruler"].active .switch { background: #2f7dca; }
.manage-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.manage-grid button { height: 34px; border-radius: 9px; color: #526078; background: #e8edf4; font-size: 9px; font-weight: 600; }
.manage-grid span { font-size: 14px; vertical-align: -1px; margin-right: 2px; }
.manage-grid .danger-soft { color: #c94646; background: #fff0ee; }
.clear-actions { grid-template-columns: 1fr; }
.download-btn {
  width: 100%; margin-top: 7px; padding: 9px 12px; display: flex; align-items: center; gap: 11px; text-align: left;
  color: white; border-radius: 11px; background: linear-gradient(135deg,#13a47b,#0d816c); box-shadow: 0 7px 16px rgba(19,164,123,.2);
}
.download-btn > span { font-size: 19px; }
.download-btn strong, .download-btn small { display: block; }
.download-btn strong { font-size: 10px; }
.download-btn small { font-size: 8px; opacity: .75; }
.option-row { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 7px 2px; cursor: pointer; }
.option-row span b, .option-row span small { display: block; }
.option-row span b { font-size: 10px; }
.option-row span small { font-size: 8px; color: #929cad; }
.option-row input { position: absolute; top: 50%; right: 0; width: 32px; height: 20px; margin: 0; transform: translateY(-50%); opacity: 0; cursor: pointer; z-index: 1; }
.option-row input:focus-visible { outline: none; }
.option-row input:focus-visible + i { outline: 3px solid #82a9ee; outline-offset: 3px; }
.option-row i { position: relative; width: 32px; height: 19px; border-radius: 12px; background: #dfe4eb; transition: .2s; }
.option-row i::after { content:""; position: absolute; width: 15px; height: 15px; top: 2px; left: 2px; border-radius: 50%; background: white; box-shadow: 0 1px 4px rgba(30,40,60,.2); transition: .2s; }
.option-row input:checked + i { background: var(--blue-2); }
.option-row input:checked + i::after { transform: translateX(13px); }

dialog { width: min(660px,calc(100vw - 32px)); border: 0; border-radius: 22px; padding: 27px; box-shadow: 0 30px 80px rgba(20,31,52,.28); color: var(--ink); }
dialog::backdrop { background: rgba(19,29,48,.42); backdrop-filter: blur(5px); }
dialog h2 { margin: 0 0 19px; }
.dialog-close { position: absolute; right: 15px; top: 15px; width: 32px; height: 32px; border-radius: 50%; background: #eef1f5; font-size: 20px; }
.help-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.help-grid > div { padding: 15px; border-radius: 14px; background: #f3f6fa; }
.help-grid span { display: block; color: #c28b36; font-size: 10px; font-weight: 700; }
.help-grid strong { display: block; margin: 4px 0; font-size: 12px; }
.help-grid p { margin: 0; color: #68748a; font-size: 10px; line-height: 1.5; }

@media (max-width: 930px) {
  html, body { overflow: auto; }
  .app-shell { height: auto; min-height: 100dvh; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: 70vh auto; }
  .tool-rail { overflow: visible; }
  .rail-scroll { height: auto; overflow: visible; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
  .tool-section { border: 1px solid #e3e7ee; border-radius: 14px; padding: 11px; margin: 0; }
}
@media (max-width: 620px) {
  .app-shell { grid-template-rows: 62px minmax(0,1fr); }
  .topbar { padding: 0 12px; grid-template-columns: 1fr auto; }
  .page-title { display: none; }
  .workspace { padding: 8px; gap: 8px; grid-template-rows: 67vh auto; }
  .canvas-card { padding: 9px; border-radius: 16px; }
  .canvas-heading p:not(.eyebrow), .canvas-status { display: none; }
  .canvas-heading h2 { font-size: 16px; }
  .rail-scroll { grid-template-columns: 1fr; }
  .help-grid { grid-template-columns: 1fr; }
  .top-actions .icon-btn { display: none; }
}

/* Distinct tool groups, readable Thai text and consistent control sizes. */
.rail-scroll { padding: 12px; background: #eef2f7; }
.tool-section { padding: 14px; margin: 0 0 12px; border: 1px solid #d5deea; border-radius: 14px; background: #fff; }
.tool-section:last-child { border: 1px solid #d5deea; }
.section-label { align-items: center; gap: 8px; padding: 0 0 10px; margin-bottom: 12px; border-bottom: 2px solid #e3eaf4; }
.section-label h3 { margin: 0; color: #193c71; font-size: 16px; line-height: 1.5; font-weight: 700; }
.section-label small, .instrument-name small { font-size: 12px; line-height: 1.5; color: #52627a; }
.instrument-name strong { font-size: 15px; }
.instrument-head { min-height: 62px; padding: 12px; }
.instrument-controls { padding: 0 12px 12px; }
.instrument-card { margin-bottom: 10px; border-color: #cbd7e7; box-shadow: none; }
.instrument-card.active { border-color: #86a6d6; box-shadow: none; }
.segmented button, .manage-grid button, .thickness button { font-size: 14px; color: #34455e; }
.segmented button { height: 44px; gap: 6px; }
.segmented button svg { width: 18px; height: 18px; flex-shrink: 0; }
.segmented.drawing-tools { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.segmented.point-tools { grid-template-columns: 1fr; }
.drawing-tools { background: #eff4fb; border-color: #d8e2f1; }
.drawing-tools button.active { background: #1d3f91; color: white; box-shadow: none; }
.control-label { margin: 14px 0 4px; font-size: 13px; color: #34455e; font-weight: 600; }
.palette { padding: 6px 2px 12px; }
.swatch { width: 28px; height: 28px; }
.thickness button { min-height: 36px; }
.thickness button.active { color: white; }
.adjust-control { margin: 14px 0 0; }
.adjust-control > label, .point-editor > label { font-size: 13px; line-height: 1.6; color: #34455e; font-weight: 500; }
.adjust-inputs { grid-template-columns: minmax(0, 1fr) 76px; gap: 10px; margin-top: 6px; }
.adjust-inputs input[type="number"], .point-name-row input { min-height: 40px; padding: 8px; font-size: 14px; border-color: #b6c6dc; }
.adjust-inputs input[type="range"] { min-height: 32px; }
.point-name-row { margin-top: 6px; }
.point-name-row button { padding: 8px 10px; min-height: 40px; font-size: 13px; }
.point-editor { margin-top: 14px; }
.microcopy { margin-top: 10px; font-size: 12px; line-height: 1.7; color: #52627a; }
.primary-action, .radius-lock, .ruler-preset-row button, .ruler-edge-actions button { min-height: 42px; font-size: 13px; line-height: 1.5; }
.readout-grid { margin-top: 12px; gap: 8px; }
.readout-grid label { font-size: 12px; color: #52627a; padding: 8px; }
.ruler-control-row > span, .center-pin-state, .lock-state { font-size: 12px; line-height: 1.6; color: #52627a; }
.center-pin-state { padding: 8px; text-align: center; }
.compass-size-options > summary { min-height: 40px; padding: 9px 10px; font-size: 13px; }
.manage-grid button { height: auto; min-height: 42px; padding: 7px 4px; font-size: 12px; }
.download-btn { min-height: 54px; }
.download-btn strong { font-size: 14px; }
.download-btn small { font-size: 12px; }
.option-row { gap: 12px; padding: 10px 0; }
.option-row span b { font-size: 14px; }
.option-row span small { font-size: 12px; line-height: 1.6; color: #52627a; }
.option-row i, .switch { flex-shrink: 0; }
button:disabled, input:disabled { opacity: 1; color: #65748a; background: #f1f4f8; box-shadow: none; cursor: not-allowed; }
input::placeholder { color: #65748a; opacity: 1; }
.canvas-heading p:not(.eyebrow), .canvas-status, .history-status, .import-status { font-size: 13px; }
.history-status { margin-left: auto; }
.history-actions button, .import-board-btn { font-size: 14px; }
.import-status { margin-top: 2px; color: #52627a; }
.eyebrow { font-size: 11px; letter-spacing: .5px; }
.zoom-controls button, .zoom-controls span { min-height: 38px; font-size: 13px; }
#importBtn { color: #254b87; border: 1px solid #d2def2; background: #edf3ff; box-shadow: none; }
.help-grid p { font-size: 12px; line-height: 1.65; }
.help-grid strong { font-size: 13px; }
.board-footer { height: auto; min-height: 42px; align-items: center; gap: 12px; padding-top: 7px; font-size: 12px; }
.instruction { min-width: 0; line-height: 1.5; }
.mouse-icon { flex-shrink: 0; }
.coord-readout { flex-shrink: 0; }

/* Private cloud file library */
#libraryDialog { position: relative; padding: 28px; }
#libraryDialog h2 { padding-right: 38px; margin-bottom: 8px; color: #193c71; font-size: 22px; }
#libraryDialog .cloud-note { margin: 0 0 18px; color: #52627a; font-size: 13px; line-height: 1.65; }
#libraryGate { padding: 20px; border: 1px solid #d8e2f1; border-radius: 14px; background: #f5f8fc; }
#libraryGate p { margin: 0 0 12px; color: #34455e; line-height: 1.6; }
#libraryGate button, #libraryUpload { color: white; background: #21499d; }
.library-actions { display: flex; flex-wrap: wrap; gap: 9px; margin: 14px 0; }
.library-actions button, .library-file-actions button { min-height: 40px; padding: 8px 13px; border: 1px solid #cbd7e7; border-radius: 10px; background: #f3f6fa; color: #193c71; font-size: 13px; }
.library-actions #libraryUpload { border-color: #21499d; }
.library-search-label { display: block; margin: 14px 0 5px; color: #34455e; font-size: 13px; font-weight: 600; }
#librarySearch { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid #cbd7e7; border-radius: 10px; font-size: 14px; }
#libraryContent > .cloud-note { margin: 8px 0 12px; font-size: 12px; }
.library-list { display: grid; gap: 9px; max-height: min(48vh, 460px); overflow-y: auto; }
.library-file { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px; border: 1px solid #d8e2f1; border-radius: 12px; background: white; }
.library-file-info { display: grid; gap: 5px; min-width: 0; }
.library-file-info strong { overflow-wrap: anywhere; color: #1d2f4c; font-size: 14px; }
.library-file-info small { color: #52627a; font-size: 12px; }
.library-file-actions { display: flex; flex-shrink: 0; gap: 7px; }
.library-file-actions button:first-child { border-color: #21499d; background: #21499d; color: white; }
.library-empty { padding: 22px 14px; border: 1px dashed #b9c8dc; border-radius: 12px; color: #52627a; text-align: center; line-height: 1.6; }
#libraryMessage { min-height: 1.5em; margin: 12px 0 0; }
#libraryMessage[data-error="true"] { color: #b42318; }
@media (max-width: 620px) {
  #libraryDialog { padding: 22px 16px; }
  .library-file { align-items: stretch; flex-direction: column; }
  .library-file-actions button { flex: 1; }
}
@media (max-width: 620px) {
  .board-wrap { min-height: 180px; }
  .history-actions button { padding: 7px 10px; font-size: 13px; }
  .history-status { flex-basis: 100%; margin-left: 0; font-size: 12px; }
  .coord-readout { display: none; }
  .canvas-heading { padding-bottom: 8px; }
}
