/* ===== Garage Planner — styles =====
   Blueprint feel: near-white canvas, blue-tinted grid, one accent color. */

:root {
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --ink: #1f2937;
  --ink-soft: #64748b;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --line: #dbe4ef;
  --danger: #dc2626;
  --topbar-h: 52px;
  --toolbar-h: 68px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* display:flex on panels must not defeat the hidden attribute */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  height: 100vh;   /* fallback */
  height: 100dvh;  /* iOS Safari dynamic viewport */
  display: flex;
  flex-direction: column;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { opacity: 0.35; cursor: default; }

/* ===== Top bar ===== */
#topbar {
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  padding-top: env(safe-area-inset-top);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.plan-name {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 16px;
}
.plan-name:active { background: var(--bg); }
.plan-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.plan-name .chev { width: 18px; height: 18px; flex: 0 0 auto; color: var(--ink-soft); }

.icon-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active:not(:disabled) { background: var(--bg); }
.icon-btn.accent { background: var(--accent); color: #fff; }
.icon-btn.accent:active { background: var(--accent-dark); }

/* ===== Canvas ===== */
#canvasWrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #f7fafd;
  touch-action: none;   /* one-finger drawing must not scroll the page */
  outline: none;
}

.float-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(15, 40, 80, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
}
.float-btn svg { width: 22px; height: 22px; }
.float-btn:active { background: var(--bg); }

/* Floating action bar for selection */
.action-bar {
  position: absolute;
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(15, 40, 80, 0.22);
  transform: translate(-50%, -100%);
  z-index: 15;
  white-space: nowrap;
}
.action-bar button {
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}
.action-bar button:active { background: var(--bg); }
.action-bar button.danger { color: var(--danger); }

/* ===== Bottom toolbar ===== */
#toolbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  gap: 2px;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 20;
}

.tool-btn {
  flex: 1 1 0;
  min-width: 48px;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 12px;
  color: var(--ink-soft);
}
.tool-btn svg { width: 24px; height: 24px; }
.tool-btn span { font-size: 11px; font-weight: 600; }
.tool-btn.active {
  color: var(--accent);
  background: #e8effd;
}

/* ===== Overlays ===== */
#scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 40, 0.42);
  z-index: 30;
}

.panel {
  position: fixed;
  z-index: 31;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 10px 34px rgba(10, 25, 50, 0.3);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel h2 { font-size: 17px; }

.panel.center {
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
  width: min(92vw, 360px);
  max-height: 80vh;
  max-height: 80dvh;
  overflow-y: auto;
}

.panel.sheet {
  left: 8px;
  right: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  border-radius: 18px;
}

.panel label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}
.panel input[type="number"], .panel input[type="text"] {
  font: inherit;
  font-size: 17px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--bg);
  -webkit-user-select: text;
  user-select: text;
}
.panel input:focus { outline: 2px solid var(--accent); border-color: transparent; }

.panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.btn {
  height: 46px;
  padding: 0 16px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  background: var(--bg);
  color: var(--ink);
}
.btn:active { filter: brightness(0.94); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: none; color: var(--ink-soft); }
.btn.big { width: 100%; height: 52px; }
.btn.danger-soft { background: #fdeeee; color: var(--danger); margin-top: 4px; }

/* Plans list */
.plans-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 46vh;
  overflow-y: auto;
}
.plan-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}
.plan-row.current { border-color: var(--accent); background: #e8effd; }
.plan-row .row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}
.plan-row .row-name {
  flex: 1;
  text-align: left;
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 34px;
}
.plan-row .row-actions { display: flex; gap: 2px; }
.plan-row .row-actions button {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  padding: 8px;
  border-radius: 8px;
}
.plan-row .row-actions button.danger { color: var(--danger); }
.plan-row .row-actions button:active { background: rgba(0,0,0,0.06); }

/* Measure sheet (numeric entry) */
#measurePanel { gap: 10px; }
#measurePanel h2 { font-size: 16px; }
.measure-fields { display: flex; flex-direction: column; gap: 10px; }
.mrow { display: flex; align-items: flex-end; gap: 10px; }
.mrow-label {
  flex: 0 0 62px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  padding-bottom: 12px;
}
.mcell { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.mcell label { font-size: 11px; font-weight: 600; color: var(--ink-soft); }
.mcell input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  text-align: center;
  -webkit-user-select: text;
  user-select: text;
}
.mcell input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.mquick { display: flex; gap: 6px; align-items: flex-end; padding-bottom: 1px; }
.mquick button {
  height: 40px;
  padding: 0 12px;
  border-radius: 9px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.mquick button:active { filter: brightness(0.94); }

/* Version stamp in the settings dialog */
.app-version {
  text-align: center;
  font-size: 11px;
  color: #9aa8ba;
  margin-top: 2px;
}

/* Toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--toolbar-h) + 24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 40;
  max-width: 86vw;
  text-align: center;
  pointer-events: none;
}
