:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #17202a;
  --muted: #64748b;
  --line: #cbd5e1;
  --panel: #ffffff;
  --accent: #1e7a78;
  --accent-strong: #125b59;
  --blue: #25415f;
  --paper: #f8fafc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  min-height: 100vh;
  color: var(--ink);
  background: #e9eef3;
}

body.auth-pending .app-shell {
  display: none;
}

body:not(.auth-pending) .auth-gate {
  display: none;
}

body.auth-loading .auth-gate {
  display: none;
}

body.auth-loading .toolbar > *,
body.auth-loading .topbar > *,
body.auth-loading .workspace-frame > * {
  visibility: hidden;
}

body.readonly-share .toolbar,
body.readonly-share .canvas-menu,
body.readonly-share .cloud-panel {
  display: none;
}

body.readonly-share .app-shell {
  grid-template-columns: minmax(0, 1fr);
}

body.readonly-share .topbar {
  justify-content: flex-start;
}

body.readonly-share .share-menu-controls {
  display: block;
}

body.readonly-share .shared-service-link {
  display: flex;
}

body.readonly-share #board {
  cursor: default;
}

body.readonly-share .shape {
  touch-action: none;
}

body.readonly-share .share-mode-controls {
  display: flex;
}

body.readonly-share .share-layer-controls {
  display: block;
}

body.readonly-share .share-layer-controls[hidden] {
  display: none;
}

body.readonly-share .selection-summary {
  cursor: pointer;
}

button,
input,
select {
  font: inherit;
}

.auth-gate {
  display: grid;
  width: 100vw;
  height: 100vh;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef4f7 0%, #e7edf2 48%, #f7fafc 100%);
}

.auth-card {
  display: grid;
  grid-template-columns: minmax(0, 390px) minmax(300px, 470px);
  align-items: center;
  gap: 32px;
  width: min(940px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.16);
}

.auth-card-body {
  display: grid;
  gap: 14px;
}

.auth-kicker {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
}

.auth-brand-mark {
  display: block;
  width: 52px;
  height: 52px;
  border-radius: 8px;
}

.auth-card h1 {
  margin: 0;
  font-size: 24px;
}

.auth-card p,
.auth-status {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.auth-card p {
  margin: 0;
}

.auth-flow {
  display: grid;
  gap: 12px;
  margin-top: 4px;
  padding-top: 4px;
}

.auth-flow-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.auth-flow-number {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid #b9d9d6;
  border-radius: 8px;
  color: var(--accent-strong);
  background: #f1fbfa;
  font-size: 12px;
  font-weight: 900;
}

.auth-flow-item strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 14px;
}

.auth-flow-item p {
  font-size: 13px;
}

.auth-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-top: 4px;
}

.auth-card-body .google-login-button {
  width: 100%;
}

.auth-preview-image {
  width: 100%;
  min-width: 0;
  border: 1px solid #d5e2eb;
  border-radius: 8px;
  background: #edf3f6;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.auth-preview-panel {
  display: grid;
  gap: 12px;
}

.auth-preview-caption {
  display: grid;
  gap: 4px;
  padding-left: 2px;
}

.auth-preview-caption strong {
  font-size: 14px;
}

.auth-preview-caption span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.auth-status:empty {
  display: none;
}

.google-login-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid #747775;
  border-radius: 999px;
  color: #1f1f1f;
  background: #fff;
  font-family: Roboto, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  cursor: pointer;
}

.google-login-button:hover:not(:disabled) {
  background: #f8fafd;
  border-color: #747775;
}

.google-login-button:active:not(:disabled) {
  background: #f1f3f4;
}

.google-login-button:focus-visible {
  outline: 3px solid rgba(66, 133, 244, 0.35);
  outline-offset: 2px;
}

.google-login-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.google-login-button.compact {
  min-height: 34px;
  gap: 8px;
  padding: 0 12px;
}

.google-g-mark,
.google-g-mark svg {
  display: block;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.secondary-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid #b9d9d6;
  border-radius: 8px;
  color: var(--accent-strong);
  background: #eef7f6;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.secondary-button:hover:not(:disabled),
.secondary-button:focus-visible {
  border-color: var(--accent);
  color: #0f4f4d;
  outline: none;
}

.secondary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.walkthrough-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.46);
}

.walkthrough-overlay[hidden] {
  display: none;
}

.walkthrough-dialog {
  position: relative;
  display: grid;
  gap: 20px;
  width: min(760px, 100%);
  max-height: min(720px, calc(100vh - 48px));
  overflow: auto;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 70px rgba(15, 23, 42, 0.28);
}

.walkthrough-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.walkthrough-header {
  display: grid;
  gap: 8px;
  padding-right: 42px;
}

.walkthrough-header h2 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.2;
}

.walkthrough-header p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.walkthrough-steps {
  min-height: 208px;
}

.walkthrough-step {
  display: none;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 20px;
  align-items: center;
}

.walkthrough-step.is-active {
  display: grid;
}

.walkthrough-step img {
  width: 96px;
  height: 96px;
  border: 1px solid #d5e2eb;
  border-radius: 8px;
  background: #f8fafc;
}

.walkthrough-step span {
  display: block;
  margin-bottom: 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
}

.walkthrough-step h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.25;
}

.walkthrough-step p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.walkthrough-controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.walkthrough-controls .primary-button,
.walkthrough-controls .secondary-button {
  width: auto;
  min-width: 96px;
}

.walkthrough-progress {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

@media (max-width: 720px) {
  .auth-gate {
    align-items: start;
    height: 100svh;
    min-height: 100dvh;
    padding: 14px 14px calc(230px + env(safe-area-inset-bottom, 0px));
    overflow: auto;
    overscroll-behavior: contain;
    scroll-padding-bottom: calc(230px + env(safe-area-inset-bottom, 0px));
  }

  .auth-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    padding: 20px;
  }

  .auth-preview-image {
    order: -1;
  }

  .auth-preview-panel {
    order: -1;
  }

  .auth-actions {
    position: fixed;
    z-index: 70;
    right: 14px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    left: 14px;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    margin: 0;
    padding: 10px;
    border: 1px solid rgba(203, 213, 225, 0.92);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.16);
    backdrop-filter: blur(10px);
  }

  .auth-actions .google-login-button,
  .auth-actions .secondary-button {
    min-height: 44px;
  }

  .walkthrough-overlay {
    align-items: end;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .walkthrough-dialog {
    max-height: min(680px, calc(100vh - 24px));
    padding: 20px;
  }

  .walkthrough-step {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .walkthrough-step img {
    width: 76px;
    height: 76px;
  }

  .walkthrough-controls {
    grid-template-columns: 1fr 1fr;
  }

  .walkthrough-progress {
    grid-column: 1 / -1;
    grid-row: 1;
  }
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.sidebar-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.sidebar-tab {
  display: grid;
  min-height: 46px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  font-size: 24px;
  font-weight: 800;
  cursor: pointer;
}

.sidebar-tab.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.sidebar-panel {
  display: grid;
  gap: 18px;
}

.sidebar-panel[hidden] {
  display: none;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: block;
  border-radius: 8px;
  flex: 0 0 auto;
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

p {
  margin: 0;
}

.brand p,
.paste-box p,
.status,
.beta-panel p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.beta-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #b9d9d6;
  border-radius: 8px;
  background: #f1fbfa;
}

.beta-heading,
.beta-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.beta-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.beta-panel a {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.beta-panel a:hover {
  text-decoration: underline;
}

.help-panel {
  padding-bottom: 14px;
}

.shortcut-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shortcut-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

kbd {
  display: inline-grid;
  min-height: 22px;
  min-width: 28px;
  place-items: center;
  padding: 0 6px;
  border: 1px solid #b7c4d1;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
}

.tool-section {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.tool-button,
.wide-button,
.primary-button,
.account-button,
.file-button,
.menu-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

.tool-button {
  font-size: 20px;
  font-weight: 700;
}

.tool-button.is-active {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.active-tool-label {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef7f6;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.wide-button {
  grid-column: span 2;
  font-weight: 700;
}

.export-control {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.export-control label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.export-control select {
  width: 100%;
}

.export-control .wide-button {
  grid-column: 1 / -1;
  width: 100%;
}

.primary-button {
  width: 100%;
  color: #fff;
  border-color: var(--accent-strong);
  background: var(--accent);
  font-weight: 800;
}

.danger-button {
  color: #b42318;
  border-color: #f3b3ad;
  background: #fff5f4;
}

.file-button {
  display: grid;
  width: 100%;
  place-items: center;
  color: var(--accent-strong);
  background: #eef7f6;
  font-weight: 800;
}

.file-button input {
  display: none;
}

.control-group {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.control-group label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.group-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.field-grid label {
  display: grid;
  gap: 4px;
}

select,
.number-field,
#unitScale,
.canvas-name-input {
  width: 96px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.canvas-panel label {
  display: grid;
  gap: 6px;
}

.canvas-menu-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.canvas-menu-panel select,
.canvas-name-input {
  width: 100%;
  padding: 0 8px;
}

.canvas-menu-panel .wide-button {
  grid-column: 1 / -1;
  width: 100%;
}

.share-url-output {
  width: 100%;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid #b9d9d6;
  border-radius: 6px;
  background: #f1fbfa;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.number-field {
  width: 100%;
  padding: 0 8px;
}

.compact-actions {
  grid-template-columns: 1fr 1fr;
}

.mini-button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.layer-list {
  display: grid;
  gap: 6px;
}

.layer-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: grab;
}

.layer-item:active {
  cursor: grabbing;
}

.layer-item.is-dragging {
  opacity: 0.45;
}

.layer-item.is-drop-before {
  box-shadow: inset 0 3px 0 var(--accent);
}

.layer-item.is-drop-after {
  box-shadow: inset 0 -3px 0 var(--accent);
}

.layer-item.is-active {
  border-color: var(--accent);
  background: #eef7f6;
}

.layer-radio,
.layer-visible {
  display: flex !important;
  justify-content: flex-start !important;
  gap: 6px;
  min-width: 0;
}

.layer-radio span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-name {
  cursor: text;
}

.layer-name-input {
  width: 100%;
  min-width: 0;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.panel-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.cloud-panel {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 320px;
  width: 320px;
}

.cloud-copy {
  display: grid;
  gap: 2px;
  width: 190px;
  min-width: 190px;
  text-align: right;
}

.cloud-state {
  display: block;
  min-height: 18px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 18px;
}

.cloud-account {
  display: block;
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 16px;
  overflow-wrap: anywhere;
}

.account-button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  background: #eef7f6;
}

.account-button.google-login-button {
  color: #1f1f1f;
  background: #fff;
  border-color: #747775;
  font-size: 13px;
  font-weight: 500;
}

.cloud-panel .account-button[hidden] {
  display: none;
}

.symbol-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 250px;
  overflow: auto;
  padding-right: 2px;
}

.symbol-panel[hidden] {
  display: none;
}

.symbol-option {
  display: grid;
  gap: 4px;
  min-height: 82px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.symbol-option.is-active {
  border-color: var(--accent);
  background: #eef7f6;
  color: var(--accent-strong);
}

.symbol-option svg {
  width: 100%;
  height: 42px;
}

.wide-button:disabled,
.number-field:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

input[type="color"] {
  width: 54px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.paste-box {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.workspace-wrap {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  height: 100vh;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  min-height: 58px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.shared-service-link {
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #b9d9d6;
  border-radius: 8px;
  color: var(--accent-strong);
  background: #f1fbfa;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.shared-service-link:hover,
.shared-service-link:focus-visible {
  border-color: var(--accent);
  color: #0f4f4d;
  outline: none;
}

.shared-service-link img {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  flex: 0 0 auto;
}

.canvas-menu {
  position: relative;
  flex: 0 0 auto;
}

.menu-button {
  min-height: 34px;
  padding: 0 14px;
  color: var(--accent-strong);
  background: #eef7f6;
  font-size: 13px;
  font-weight: 800;
}

.menu-button[aria-expanded="true"] {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.canvas-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  display: grid;
  gap: 10px;
  width: 280px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.16);
}

.canvas-menu-section {
  display: grid;
  gap: 10px;
}

.canvas-menu-section + .canvas-menu-section {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.canvas-menu-panel[hidden] {
  display: none;
}

.selection-summary {
  flex: 0 0 auto;
  min-width: 150px;
}

.selection-summary:focus-visible {
  outline: 3px solid rgba(30, 122, 120, 0.35);
  outline-offset: 3px;
}

.share-menu-controls {
  position: relative;
  display: none;
  flex: 0 0 auto;
}

.share-menu-controls > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  list-style: none;
}

.share-menu-controls > summary::-webkit-details-marker {
  display: none;
}

.share-menu-controls[open] > summary {
  border-color: var(--accent);
  background: var(--accent);
}

.share-menu-icon,
.share-menu-icon::before,
.share-menu-icon::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--blue);
}

.share-menu-icon {
  position: relative;
}

.share-menu-icon::before,
.share-menu-icon::after {
  position: absolute;
  left: 0;
  content: "";
}

.share-menu-icon::before {
  top: -6px;
}

.share-menu-icon::after {
  top: 6px;
}

.share-menu-controls[open] .share-menu-icon,
.share-menu-controls[open] .share-menu-icon::before,
.share-menu-controls[open] .share-menu-icon::after {
  background: #fff;
}

.share-menu-panel {
  position: absolute;
  z-index: 24;
  top: calc(100% + 8px);
  left: 0;
  display: grid;
  gap: 10px;
  width: min(300px, calc(100vw - 24px));
  padding: 10px;
  border: 1px solid #b9d9d6;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
}

.share-mode-controls {
  display: none;
  flex: 0 0 auto;
}

.share-mode-toggle {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--blue);
  background: #fff;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.share-mode-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.share-menu-panel .shared-service-link,
.share-menu-panel .share-mode-controls,
.share-menu-panel .share-layer-controls,
.share-menu-panel .share-mode-toggle {
  width: 100%;
}

.share-menu-panel .share-layer-list {
  position: static;
  width: 100%;
  max-height: min(260px, calc(100vh - 180px));
  margin-top: 8px;
  box-shadow: none;
}

.share-menu-panel .share-layer-all-button {
  position: static;
  width: 100%;
  margin-top: 8px;
}

.share-layer-controls {
  position: relative;
  display: none;
  flex: 0 0 auto;
}

.share-layer-controls summary {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  list-style: none;
}

.share-layer-controls summary::-webkit-details-marker {
  display: none;
}

.share-layer-controls[open] summary {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.share-layer-list {
  position: absolute;
  z-index: 24;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  gap: 6px;
  width: min(280px, calc(100vw - 24px));
  max-height: min(360px, calc(100vh - 96px));
  padding: 10px 10px 46px;
  overflow: auto;
  border: 1px solid #b9d9d6;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
}

.share-layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid #d4dee8;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.share-layer-item input {
  flex: 0 0 auto;
}

.share-layer-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-layer-all-button {
  position: absolute;
  z-index: 25;
  right: 10px;
  bottom: 10px;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.selection-detail-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 18px;
  display: none;
  min-width: min(320px, calc(100vw - 24px));
  padding: 12px;
  border: 1px solid #b9d9d6;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
}

body.readonly-share .selection-detail-popover:not([hidden]) {
  display: block;
}

.selection-detail-popover p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.selection-detail-popover dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
  font-size: 13px;
}

.selection-detail-popover dt {
  color: var(--muted);
  font-weight: 800;
}

.selection-detail-popover dd {
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-weight: 900;
  overflow-wrap: anywhere;
}

#positionLabel {
  margin-left: 12px;
  color: var(--muted);
  font-size: 13px;
}

.distance-readout {
  flex: 1 1 auto;
  color: var(--blue);
  font-size: 14px;
  font-weight: 800;
  text-align: right;
}

.workspace-frame {
  position: relative;
  min-height: 0;
  overflow: auto;
  background: #dfe7ef;
}

.workspace-frame.is-dragging {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

#board {
  display: block;
  min-width: 1100px;
  min-height: 700px;
  outline: none;
  cursor: crosshair;
}

.inline-text-editor {
  position: absolute;
  z-index: 15;
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-width: 240px;
  padding: 6px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
}

.inline-text-editor[hidden] {
  display: none;
}

.inline-text-editor input {
  min-width: 0;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.inline-text-editor > input {
  padding: 0 7px;
}

.inline-text-editor label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.inline-text-editor label input {
  width: 58px;
  padding: 0 4px;
}

.shape {
  cursor: move;
}

.shape.is-locked {
  cursor: not-allowed;
}

.shape text {
  cursor: text;
  user-select: none;
}

.shape.is-locked text {
  cursor: not-allowed;
}

.selection-box,
.marquee-box {
  fill: none;
  stroke: #1b75d0;
  stroke-width: 2;
  stroke-dasharray: 6 4;
  pointer-events: none;
}

.resize-handle {
  fill: #ffffff;
  stroke: #1b75d0;
  stroke-width: 2;
  cursor: nwse-resize;
}

.resize-handle[data-handle="ne"],
.resize-handle[data-handle="sw"] {
  cursor: nesw-resize;
}

.resize-handle[data-handle="n"],
.resize-handle[data-handle="s"] {
  cursor: ns-resize;
}

.resize-handle[data-handle="e"],
.resize-handle[data-handle="w"] {
  cursor: ew-resize;
}

.rotate-stem {
  stroke: #1b75d0;
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  pointer-events: none;
}

.rotate-handle {
  fill: #ffffff;
  stroke: #1b75d0;
  stroke-width: 2;
  cursor: grab;
}

.rotate-handle:active {
  cursor: grabbing;
}

.corner-radius-handle {
  fill: #f08a24;
  stroke: #ffffff;
  stroke-width: 2;
  cursor: move;
}

.marquee-box {
  fill: rgba(27, 117, 208, 0.12);
}

.shape-preview {
  fill-opacity: 0.3;
  stroke-dasharray: 6 4;
  pointer-events: none;
}

.rotation-angle-label {
  fill: #1b496f;
  stroke: #ffffff;
  stroke-width: 4;
  paint-order: stroke fill;
  font-size: 18px;
  font-weight: 900;
  pointer-events: none;
}

.drag-size-label {
  fill: #1b496f;
  stroke: #ffffff;
  stroke-width: 5;
  paint-order: stroke fill;
  font-size: 18px;
  font-weight: 900;
  pointer-events: none;
}

.measure-line {
  stroke: var(--accent);
  stroke-width: 2;
  marker-start: url(#arrowStart);
  marker-end: url(#arrowEnd);
  pointer-events: none;
}

.measure-zero-marker {
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  pointer-events: none;
}

.measure-guide {
  stroke: #8aa5a5;
  stroke-width: 1;
  stroke-dasharray: 5 5;
  pointer-events: none;
}

.measure-label {
  fill: var(--accent-strong);
  font-size: 14px;
  font-weight: 800;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 5px;
  stroke-linejoin: round;
  cursor: pointer;
  pointer-events: auto;
}

.measure-label:hover {
  fill: #0f4e4c;
  text-decoration: underline;
}

.center-guide {
  stroke: #d94747;
  stroke-width: 1.5;
  stroke-dasharray: 8 5;
  pointer-events: none;
}

.edge-overlap-guide {
  stroke: #f08a24;
  stroke-width: 4;
  stroke-linecap: round;
  pointer-events: none;
}

.context-menu {
  position: fixed;
  z-index: 30;
  display: grid;
  gap: 4px;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.2);
}

.context-menu[hidden] {
  display: none;
}

.context-menu button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.context-menu button:hover {
  background: #eef7f6;
}

.context-menu button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.5;
}

.context-menu button:disabled:hover {
  background: transparent;
}

#selfTestPanel {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: 18px;
  width: min(360px, calc(100vw - 36px));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 42px rgba(15, 23, 42, 0.18);
  font-size: 13px;
}

#selfTestPanel ul {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

#selfTestPanel li[data-pass="true"] {
  color: var(--accent-strong);
}

#selfTestPanel li[data-pass="false"] {
  color: #b42318;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .toolbar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  body.readonly-share,
  body.readonly-share .app-shell,
  body.readonly-share .workspace-wrap {
    height: 100dvh;
    min-height: 100svh;
  }

  body.readonly-share .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "summary menu"
      "distance distance";
    align-items: center;
    gap: 8px 10px;
    min-height: 92px;
    padding: 8px 10px;
  }

  body.readonly-share .selection-summary {
    grid-area: summary;
    min-width: 0;
    max-width: 100%;
    padding: 7px 10px;
    border: 1px solid #d4dee8;
    border-radius: 8px;
    background: #ffffff;
    text-align: left;
  }

  body.readonly-share .share-menu-controls {
    grid-area: menu;
    justify-self: end;
  }

  body.readonly-share .share-menu-panel {
    right: 0;
    left: auto;
    width: min(300px, calc(100vw - 20px));
    max-height: calc(100svh - 120px);
    overflow: auto;
  }

  body.readonly-share .share-mode-controls {
    justify-content: stretch;
    min-width: 0;
  }

  body.readonly-share .share-mode-toggle {
    width: 100%;
    min-width: 86px;
    padding: 0 9px;
    font-size: 12px;
  }

  body.readonly-share .share-layer-controls summary {
    width: 100%;
    min-height: 34px;
    justify-content: center;
    font-size: 12px;
  }

  body.readonly-share .share-layer-list {
    width: 100%;
    max-height: min(220px, calc(100svh - 270px));
  }

  body.readonly-share #selectionLabel,
  body.readonly-share #positionLabel {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.readonly-share #positionLabel {
    margin-left: 0;
    font-size: 11px;
  }

  body.readonly-share .distance-readout {
    grid-area: distance;
    width: 100%;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid #b9d9d6;
    border-radius: 8px;
    background: #f1fbfa;
    font-size: 12px;
    line-height: 1.35;
    text-align: left;
  }

  body.readonly-share .workspace-frame {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  body.readonly-share #board {
    touch-action: none;
  }

  body.readonly-share .selection-detail-popover {
    top: 86px;
    right: 10px;
    left: 10px;
    min-width: 0;
  }
}
