﻿:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #697586;
  --line: #dfe4ea;
  --blue: #1769e0;
  --blue-soft: #eaf2ff;
  --amber: #f6b817;
  --green: #17a673;
  --danger: #d73a49;
  font-family: Inter, "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; }
button, .button { cursor: pointer; }
.topbar { height: 72px; padding: 0 22px; display: flex; align-items: center; justify-content: space-between; background: #172131; color: white; box-shadow: 0 2px 12px #12203420; }
h1 { font-size: 19px; margin: 0 0 4px; letter-spacing: .03em; }
.topbar p { margin: 0; font-size: 12px; color: #aebbd0; }
.file-actions { display: flex; gap: 8px; }
.button, button { border: 0; border-radius: 7px; padding: 9px 13px; background: white; color: var(--ink); }
.topbar .secondary { background: #263448; color: #e5ecf7; border: 1px solid #3c4b61; }
.button input { display: none; }
main { display: grid; grid-template-columns: 230px minmax(400px, 1fr) 270px; height: calc(100% - 72px); }
.panel { background: var(--panel); padding: 18px; overflow-y: auto; }
.tools { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: #566274; margin: 0 0 13px; }
h3 { font-size: 15px; margin: 10px 0 14px; }
.tool-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tool { height: 64px; border: 1px solid var(--line); background: #f9fafb; font-size: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.tool span { font-size: 12px; }
.tool:hover { border-color: #9bbcf2; background: #f5f9ff; }
.tool.active { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.divider { height: 1px; background: var(--line); margin: 20px 0; }
label { display: block; color: #4c5869; font-size: 12px; margin: 12px 0; }
input, select, textarea { width: 100%; border: 1px solid #ccd3dc; border-radius: 6px; padding: 9px 10px; margin-top: 6px; color: var(--ink); background: white; }
textarea { resize: vertical; min-height: 64px; line-height: 1.45; }
.ruler-box { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--line); }
.ruler-box h3 { margin-bottom: 8px; color: #566274; }
.ruler-box .row button { padding: 8px 5px; font-size: 11px; }
.input-unit { position: relative; }
.input-unit input { padding-right: 42px; }
.input-unit span { position: absolute; right: 10px; top: 15px; color: var(--muted); font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; margin: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.secondary { border: 1px solid var(--line); background: #f8fafc; }
.primary { background: var(--blue); color: white; }
.danger { background: #fff0f1; color: var(--danger); border: 1px solid #facdd1; }
.danger-text { color: var(--danger); background: transparent; }
.wide { width: 100%; margin-top: 9px; }
.workspace { min-width: 0; display: grid; grid-template-rows: 1fr 29px; }
#canvasWrap { position: relative; overflow: hidden; background: #e9edf2; }
#canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#emptyHint { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #768296; gap: 8px; }
#emptyHint strong { font-size: 20px; color: #566274; }
#emptyHint span { max-width: calc(100% - 28px); padding: 0 8px; font-size: 13px; line-height: 1.55; text-align: center; }
.area-summary { position: absolute; left: 16px; right: 16px; bottom: 14px; z-index: 3; max-height: 116px; padding: 9px 11px; border: 1px solid #cfe3da; border-radius: 9px; background: rgba(255,255,255,.94); box-shadow: 0 5px 18px #17213120; backdrop-filter: blur(5px); }
.area-summary-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; color: #087c54; font-size: 12px; }
.area-summary-head button { padding: 3px 7px; background: #edf8f4; color: #087c54; font-size: 10px; }
.area-summary-list { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; }
.area-chip { flex: none; display: flex; align-items: center; gap: 7px; padding: 6px 9px; border-radius: 6px; background: #e9f8f2; color: #166b50; font-size: 11px; }
.area-chip b { display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; background: #17a673; color: white; }
.remove-area-btn { display: grid; place-items: center; width: 19px; height: 19px; padding: 0; border-radius: 50%; background: transparent; color: #708078; font-size: 16px; line-height: 1; }
.remove-area-btn:hover { background: #ffe5e7; color: var(--danger); }
#toast { position: absolute; left: 50%; bottom: 20px; transform: translate(-50%, 10px); opacity: 0; pointer-events: none; background: #172131ed; color: white; border-radius: 7px; padding: 9px 14px; font-size: 12px; transition: .2s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.statusbar { background: white; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; padding: 0 12px; color: var(--muted); font-size: 11px; }
.statusbar > span { flex: 1; }
.statusbar > span:last-child { text-align: right; }
.zoom-controls { height: 24px; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; background: #f8fafc; }
.zoom-controls button { min-width: 28px; height: 23px; padding: 0 7px; border-radius: 0; background: transparent; color: #536174; font-size: 13px; }
.zoom-controls button + button { border-left: 1px solid var(--line); }
.zoom-controls button:hover { background: var(--blue-soft); color: var(--blue); }
#zoomResetBtn { min-width: 57px; font-size: 11px; }
.empty-card { color: var(--muted); text-align: center; font-size: 13px; line-height: 1.6; padding: 22px 8px; }
.empty-icon { font-size: 36px; color: #9aa6b6; }
.inspector-card { border: 1px solid var(--line); border-radius: 9px; padding: 14px; background: #fbfcfe; }
.hidden { display: none !important; }
.badge { display: inline-block; border-radius: 20px; padding: 4px 8px; background: var(--blue-soft); color: var(--blue); font-size: 11px; font-weight: 700; }
.badge.amber { background: #fff5d9; color: #9c6b00; }
.badge.green { background: #e5f8f1; color: #087c54; }
.muted { color: var(--muted); font-size: 11px; line-height: 1.6; }
.metric { background: white; border: 1px solid var(--line); padding: 9px; border-radius: 6px; font-size: 12px; color: var(--muted); }
.intersection-item { display: flex; justify-content: space-between; gap: 8px; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 12px; }
.intersection-item strong { color: var(--blue); }
.area-value { display: flex; align-items: baseline; gap: 6px; padding: 10px 0; }
.area-value strong { font-size: 35px; color: var(--green); letter-spacing: -.03em; }
.area-value span { color: var(--muted); }
.help { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 10px; }
.help h3 { font-size: 12px; color: var(--muted); }
dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 10px; font-size: 11px; margin: 0; }
dt { font-weight: 700; color: #4d596a; } dd { margin: 0; color: var(--muted); }
.mobile-nav, .mobile-backdrop, .mobile-quick-undo { display: none; }

@media (max-width: 1100px) {
  .topbar { position: relative; z-index: 40; }
  .mobile-nav { display: flex; gap: 6px; }
  .mobile-nav button { padding: 8px 10px; white-space: nowrap; }
  .topbar .mobile-nav button { background: var(--blue); color: white; border-color: #6ba4f2; font-weight: 700; box-shadow: 0 3px 10px #0a4da840; }
  .topbar .mobile-nav button[aria-expanded="true"] { background: #0f55bb; box-shadow: inset 0 0 0 2px #ffffff55; }
  main { display: block; height: calc(100% - 72px); }
  .workspace { height: 100%; }
  .panel { position: fixed; top: 72px; bottom: 0; z-index: 30; width: min(88vw, 330px); height: auto; transition: transform .22s ease, box-shadow .22s ease; }
  .tools { left: 0; border-right: 1px solid var(--line); transform: translateX(-102%); }
  .inspector { right: 0; border-left: 1px solid var(--line); transform: translateX(102%); }
  body.tools-open .tools, body.inspector-open .inspector { transform: translateX(0); box-shadow: 0 12px 34px #17213138; }
  .mobile-backdrop { position: fixed; inset: 72px 0 0; z-index: 25; width: auto; height: auto; padding: 0; border: 0; border-radius: 0; background: #17213166; }
  body.tools-open .mobile-backdrop, body.inspector-open .mobile-backdrop { display: block; }
}

@media (max-width: 680px) {
  .topbar { height: 112px; padding: 9px 11px; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 42px 42px; gap: 7px 8px; align-content: center; }
  .topbar h1 { margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar p { display: none; }
  .file-actions { grid-column: 1 / -1; grid-row: 2; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  .file-actions::-webkit-scrollbar { display: none; }
  .file-actions > button, .file-actions > .button { flex: 0 0 auto; min-height: 38px; padding: 7px 10px; font-size: 11px; text-align: center; white-space: nowrap; }
  .mobile-nav { grid-column: 2; grid-row: 1; align-self: center; }
  .mobile-nav button { min-height: 36px; padding: 7px 8px; font-size: 11px; }
  .mobile-quick-undo { display: block; flex: none; min-height: 28px; padding: 4px 8px; border: 1px solid #facdd1; border-radius: 5px; background: #fff0f1; color: var(--danger); font-size: 11px; white-space: nowrap; }
  main { height: calc(100% - 112px); }
  .panel { top: 112px; width: min(90vw, 340px); padding: 14px; }
  .mobile-backdrop { inset: 112px 0 0; }
  .workspace { grid-template-rows: minmax(0, 1fr) 34px; }
  .statusbar { min-width: 0; padding: 0 7px; gap: 6px; }
  .statusbar > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #cursorStatus { display: none; }
  .zoom-controls { flex: none; }
  .zoom-controls button { min-width: 31px; }
  .area-summary { left: 8px; right: 8px; bottom: 8px; max-height: 132px; padding: 8px; }
  .area-summary-list { gap: 5px; }
  .area-chip { padding: 5px 7px; }
  #toast { bottom: 12px; max-width: calc(100% - 24px); text-align: center; }
  .tool { min-height: 58px; }
  .panel button:not(.tool), .panel .button { min-height: 40px; }
  .panel input, .panel select, .panel textarea { min-height: 42px; font-size: 16px; }
  .panel .check { min-height: 38px; }
}

@media (max-width: 390px) {
  .topbar { padding-inline: 8px; gap: 7px 5px; }
  .topbar h1 { font-size: 14px; }
  .mobile-nav { gap: 4px; }
  .mobile-nav button { padding-inline: 6px; }
  .file-actions { gap: 4px; }
  .file-actions > button, .file-actions > .button { padding-inline: 7px; }
}








