:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --panel: #ffffff;
  --canvas: #fbfdff;
  --ink: #172033;
  --muted: #7b8ba5;
  --line: #dfe7f1;
  --line-strong: #c7d3e3;
  --blue: #2f6df6;
  --blue-dark: #2458d5;
  --blue-soft: #edf4ff;
  --danger: #f14545;
  --shadow: 0 8px 22px rgba(42, 65, 105, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Inter",
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    -apple-system,
    sans-serif;
  letter-spacing: 0;
}

.login-body,
.auth-body {
  min-height: 100%;
  background: #f7f9fc;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(47, 109, 246, 0.22);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.app-root {
  min-height: 100vh;
}

.home-topbar,
.editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.brand-block,
.account-block,
.editor-title,
.editor-actions,
.panel-title {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 11px;
}

.brand-block strong,
.editor-title strong {
  font-size: 18px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 7px);
  gap: 3px;
  place-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--blue);
  box-shadow: 0 8px 16px rgba(47, 109, 246, 0.28);
}

.brand-mark span {
  width: 7px;
  height: 7px;
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  border-radius: 2px;
}

.account-block {
  gap: 18px;
  color: #6c7b96;
  font-size: 14px;
}

.ghost-action,
.back-action {
  background: transparent;
  color: #172033;
  font-weight: 700;
}

.project-view {
  min-height: calc(100vh - 58px);
  padding: 42px 24px;
}

.project-stage {
  width: min(1060px, 100%);
  margin: 0 auto;
}

.project-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.project-heading h1 {
  font-size: 28px;
  line-height: 1.2;
}

.project-heading p {
  margin-top: 6px;
  color: var(--muted);
  font-weight: 700;
}

.blue-action {
  min-height: 40px;
  border-radius: 7px;
  background: var(--blue);
  color: #ffffff;
  padding: 0 18px;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(47, 109, 246, 0.28);
}

.blue-action:hover {
  background: var(--blue-dark);
}

.blue-action:disabled {
  cursor: wait;
  opacity: 0.7;
}

.blue-action.full {
  width: 100%;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  padding: 30px;
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 26px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 8px;
}

.login-form span {
  color: #43536d;
  font-size: 13px;
  font-weight: 800;
}

.login-form input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
  box-shadow: inset 0 1px 0 rgba(18, 30, 50, 0.03);
}

.login-form input:focus {
  border-color: #a8bef5;
}

.login-error {
  border: 1px solid rgba(241, 69, 69, 0.22);
  border-radius: 8px;
  background: rgba(241, 69, 69, 0.08);
  color: #b42323;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
}

.auth-topbar {
  display: flex;
  align-items: center;
  height: 70px;
  padding: 0 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
}

.auth-topbar .brand-mark {
  width: 36px;
  height: 36px;
}

.auth-topbar .brand-block strong {
  font-size: 20px;
}

.auth-shell {
  display: grid;
  min-height: calc(100vh - 70px);
  align-content: center;
  justify-items: center;
  padding: 54px 20px 78px;
}

.auth-intro {
  display: grid;
  justify-items: center;
  margin-bottom: 26px;
  text-align: center;
}

.auth-icon {
  display: grid;
  grid-template-columns: repeat(2, 15px);
  gap: 5px;
  place-content: center;
  width: 68px;
  height: 68px;
  margin-bottom: 14px;
  border-radius: 18px;
  background: #e8f0ff;
  color: var(--blue);
}

.auth-icon span {
  width: 15px;
  height: 15px;
  border: 3px solid var(--blue);
  border-radius: 4px;
}

.auth-intro h1 {
  color: #172033;
  font-size: 26px;
  line-height: 1.25;
}

.auth-intro p {
  margin-top: 8px;
  color: #7f8ca3;
  font-size: 15px;
  font-weight: 700;
}

.auth-card {
  width: min(480px, 100%);
  overflow: hidden;
  border: 1px solid #d9e1ec;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 5px 18px rgba(31, 45, 70, 0.18);
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  height: 48px;
  border-bottom: 1px solid #dce3ee;
  background: #f3f5f9;
}

.auth-tab {
  background: transparent;
  color: #7f8ca3;
  font-weight: 800;
}

.auth-tab.is-active {
  background: #ffffff;
  color: #172033;
  box-shadow: 0 5px 18px rgba(31, 45, 70, 0.16);
}

.auth-form {
  display: grid;
  gap: 16px;
  padding: 28px 26px 26px;
}

.auth-form label {
  display: grid;
  gap: 8px;
}

.auth-form label > span {
  color: #172033;
  font-size: 14px;
  font-weight: 800;
}

.auth-form input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
  box-shadow: 0 4px 12px rgba(42, 65, 105, 0.14);
}

.auth-form input::placeholder {
  color: #8997ad;
}

.auth-form input:focus {
  border-color: #b9c9ee;
  background: #eaf2ff;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 42px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  transform: translateY(-50%);
  border-radius: 6px;
  background: transparent;
  color: #8a98ad;
  font-size: 16px;
  font-weight: 800;
}

.password-toggle:hover,
.password-toggle.is-visible {
  color: var(--blue);
  background: #edf4ff;
}

.auth-helper {
  color: #7f8ca3;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.project-card {
  display: grid;
  gap: 14px;
  min-width: 0;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 20px;
  text-align: left;
}

.project-card:hover {
  border-color: #b7c8ee;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.project-card.has-draft {
  border-color: #b7c8ee;
}

.project-card.has-draft em {
  color: var(--blue);
}

.project-card strong {
  font-size: 18px;
}

.project-card em {
  color: var(--muted);
  font-style: normal;
  font-weight: 700;
}

.project-thumb {
  display: grid;
  place-content: center;
  height: 104px;
  border-radius: 8px;
  background: #e9edf4;
}

.project-thumb.count-4 {
  grid-template-columns: repeat(2, 30px);
  gap: 5px 6px;
}

.project-thumb.count-2 {
  grid-template-columns: repeat(2, 32px);
  gap: 5px;
}

.project-thumb.count-1 {
  grid-template-columns: 30px;
}

.project-thumb.count-0 {
  grid-template-columns: 30px;
}

.project-thumb-block {
  width: 30px;
  height: 22px;
  border-radius: 5px;
  background: #9db9f5;
}

.project-thumb.count-2 .project-thumb-block {
  width: 32px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(18, 31, 52, 0.24);
  padding: 20px;
}

.project-modal {
  display: grid;
  gap: 16px;
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 18px 46px rgba(42, 65, 105, 0.22);
  padding: 18px;
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2 {
  font-size: 18px;
}

.modal-close {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: #f3f6fb;
  color: #687995;
  font-size: 20px;
  font-weight: 700;
}

.modal-close:hover {
  background: #eaf0f8;
}

.modal-actions {
  justify-content: flex-end;
}

.editor-view {
  height: 100vh;
  overflow: hidden;
  background: #f8fbff;
}

.editor-topbar {
  height: 52px;
  padding: 0 14px 0 24px;
}

.editor-title {
  gap: 16px;
}

.back-action {
  color: #7c8aa2;
  padding-right: 16px;
  border-right: 1px solid var(--line);
}

.editor-actions {
  gap: 12px;
  color: var(--muted);
  font-weight: 700;
}

#saveStateLabel {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #7a8aa3;
  font-size: 13px;
}

#saveStateLabel::before {
  content: "▧";
  color: #90a0b8;
  font-size: 13px;
}

#saveStateLabel.is-dirty {
  color: #7a8aa3;
}

#saveStateLabel.is-saved {
  color: #5d9b72;
}

#saveStateLabel.is-saved::before {
  color: #5d9b72;
}

#saveStateLabel.is-error,
#saveStateLabel.is-error::before {
  color: var(--danger);
}

.icon-action {
  display: grid;
  place-items: center;
  width: 36px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #7a8ba6;
}

.save-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #1f2937;
  min-height: 34px;
  padding: 0 10px 0 13px;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(42, 65, 105, 0.16);
}

.save-action:hover {
  border-color: #c9d4e6;
  background: #f8fbff;
}

.save-action strong {
  font-size: 14px;
}

.save-action kbd {
  min-width: 34px;
  border-radius: 6px;
  background: #eef2f7;
  padding: 2px 6px;
  color: #7c8aa2;
  font: 800 12px/1.2 "Inter", "Microsoft YaHei", system-ui, sans-serif;
}

.editor-body {
  display: grid;
  grid-template-columns: 60px 190px minmax(0, 1fr) 220px;
  height: calc(100vh - 52px);
  min-width: 0;
}

.tool-rail,
.space-panel,
.property-panel {
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.tool-rail {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 8px;
  padding: 10px 8px;
}

.rail-tab {
  width: 100%;
  height: 34px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.tool-button,
.rail-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 7px;
  background: transparent;
  color: #334055;
  font-size: 21px;
  font-weight: 800;
}

.tool-button.is-active,
.rail-tab.is-active,
.rail-icon.is-active {
  background: var(--blue);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(47, 109, 246, 0.25);
}

.rail-icon {
  margin-top: 0;
  color: #4a566b;
}

.rail-icon + .rail-icon {
  margin-top: 0;
}

.rail-icon:hover:not(:disabled),
.tool-button:hover {
  background: var(--blue-soft);
}

.rail-icon:disabled {
  cursor: default;
  color: #b8c2d1;
  opacity: 0.72;
}

.rail-separator {
  width: 38px;
  height: 1px;
  margin: 4px 0;
  background: var(--line);
}

.space-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
}

.panel-title {
  gap: 10px;
  height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.panel-title.between {
  justify-content: space-between;
}

.panel-title h2 {
  font-size: 15px;
}

.panel-icon-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: transparent;
  color: #8a9ab2;
  font-size: 17px;
  font-weight: 800;
}

.panel-icon-button:hover:not(:disabled) {
  background: #edf4ff;
  color: var(--blue);
}

.panel-icon-button:disabled {
  cursor: default;
  opacity: 0.36;
}

.tiny-grid {
  display: grid;
  grid-template-columns: repeat(2, 5px);
  gap: 3px;
}

.tiny-grid::before,
.tiny-grid::after {
  content: "";
  width: 13px;
  height: 13px;
  background:
    linear-gradient(#93a1b8 0 0) left top / 5px 5px no-repeat,
    linear-gradient(#93a1b8 0 0) right top / 5px 5px no-repeat,
    linear-gradient(#93a1b8 0 0) left bottom / 5px 5px no-repeat,
    linear-gradient(#93a1b8 0 0) right bottom / 5px 5px no-repeat;
}

.tiny-grid::after {
  display: none;
}

.space-list {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px 8px;
  overflow: auto;
}

.space-item {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 8px;
  min-width: 0;
  border-radius: 7px;
  background: transparent;
  padding: 9px 10px 9px calc(10px + var(--indent, 0px));
  text-align: left;
  transition:
    background 0.12s ease,
    padding-left 0.12s ease;
}

.space-item.is-selected {
  background: var(--blue);
  color: #ffffff;
}

.space-item.is-child:not(.is-selected) {
  background: rgba(237, 244, 255, 0.42);
}

.space-grip {
  align-self: center;
  color: #b2bdce;
  font-size: 13px;
  line-height: 1;
}

.space-item.is-selected .space-grip {
  color: rgba(255, 255, 255, 0.7);
}

.space-dot {
  width: 11px;
  height: 11px;
  margin-top: 5px;
  border-radius: 4px;
  background: var(--dot);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.space-text {
  min-width: 0;
}

.space-item strong,
.space-item em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.space-item strong {
  font-size: 14px;
}

.space-item em {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.space-item.is-selected em {
  color: rgba(255, 255, 255, 0.78);
}

.add-space-box,
.summary-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.add-space-box h3,
.property-section h3 {
  color: #6e7f9a;
  font-size: 13px;
}

.summary-box span,
.summary-box em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.summary-box strong {
  font-size: 20px;
}

.workspace {
  display: grid;
  position: relative;
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
  background: #f8fbff;
}

.workspace-header {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 6px 12px 6px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
}

.workspace-header div:first-child {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.workspace-header strong {
  font-size: 13px;
}

.workspace-header span {
  color: var(--muted);
  font-size: 12px;
}

.metric-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  padding: 6px 10px;
  color: #5f708d;
  font-size: 12px;
  font-weight: 700;
}

.canvas-frame {
  position: relative;
  min-height: 0;
}

#planCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--canvas);
  touch-action: none;
}

.canvas-zoom-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  min-width: 46px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 6px 16px rgba(42, 65, 105, 0.12);
  color: #8190a8;
  padding: 5px 9px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  pointer-events: none;
}

.canvas-hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  max-width: min(680px, calc(100% - 40px));
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 18px rgba(42, 65, 105, 0.14);
  color: #7890aa;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.property-panel {
  display: grid;
  grid-template-rows: auto auto auto auto 1fr auto;
  min-width: 0;
  border-right: 0;
  border-left: 1px solid var(--line);
  overflow: auto;
}

.property-section {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span {
  color: #8291ab;
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-width: 0;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 10px;
  box-shadow: 0 4px 12px rgba(42, 65, 105, 0.08);
}

input[type="range"] {
  padding: 0;
  box-shadow: none;
  accent-color: var(--blue);
}

.unit-input {
  position: relative;
  min-width: 0;
}

.unit-input input {
  padding-right: 33px;
}

.unit-input em {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: #8a98ad;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  pointer-events: none;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.selection-fields {
  display: grid;
  gap: 12px;
}

.measure-fields {
  display: grid;
  gap: 10px;
}

.empty-note {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}

.area-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 8px;
  border-radius: 7px;
  background: #eef2f7;
  padding: 10px 12px;
}

.area-card span {
  color: #74839b;
  font-size: 12px;
  font-weight: 700;
}

.area-card strong {
  grid-column: 1;
  font-size: 21px;
}

.area-card em {
  align-self: end;
  color: #6f809a;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.measure-card {
  background: #fff3ec;
}

.measure-card strong {
  color: #c85245;
}

.measure-note {
  color: #8190a8;
  font-size: 12px;
  line-height: 1.45;
}

.measure-clear-button {
  width: 100%;
  min-height: 34px;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(7, 23px);
  gap: 6px 5px;
}

.swatch {
  width: 23px;
  height: 23px;
  border: 2px solid transparent;
  border-radius: 6px;
  background: var(--swatch);
}

.swatch.is-active {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(47, 109, 246, 0.14);
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: 17px;
  height: 17px;
  box-shadow: none;
  accent-color: var(--blue);
}

.delete-action {
  position: sticky;
  bottom: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  align-self: end;
  min-height: 40px;
  margin: 12px;
  border-radius: 7px;
  background: var(--danger);
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(241, 69, 69, 0.24);
}

.delete-action::before {
  content: "⌫";
  font-size: 17px;
  line-height: 1;
}

.delete-action:disabled {
  cursor: default;
  background: #e8edf5;
  color: #9aa8ba;
  box-shadow: none;
}

.secondary-action {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #60728e;
  font-weight: 800;
}

.secondary-action:hover {
  border-color: #b8c7dc;
  background: #f8fbff;
}

.shortcut-card {
  display: grid;
  gap: 6px;
  margin: 12px;
  border-radius: 8px;
  background: #eef2f7;
  padding: 12px;
  color: #72829b;
}

.shortcut-card h3 {
  color: #5e6f88;
  font-size: 13px;
}

.shortcut-card p {
  color: #8190a8;
  font-size: 12px;
  line-height: 1.35;
}

.space-item[draggable="true"] {
  cursor: grab;
}

.space-item.is-drag-over {
  box-shadow: inset 0 0 0 2px rgba(47, 109, 246, 0.25);
}

@media (max-width: 1120px) {
  .editor-body {
    grid-template-columns: 54px 178px minmax(0, 1fr);
  }

  .property-panel {
    display: none;
  }

  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .home-topbar {
    padding: 0 14px;
  }

  .project-view {
    padding: 24px 14px;
  }

  .project-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

  .editor-body {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .space-panel {
    display: none;
  }

  .editor-title strong {
    display: none;
  }
}
