* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--surface-page);
  color: var(--text-body);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  overflow: hidden;
}

.screen { display: none; height: 100vh; flex-direction: column; }
.screen.is-active { display: flex; }

/* ---- Banner (boards screen) ---- */
.app-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.app-banner__brand { display: flex; align-items: center; gap: var(--space-4); }
.app-banner__divider { width: 1px; height: 24px; background: var(--border-default); }
.app-banner__title { font-weight: var(--fw-medium); color: var(--text-muted); font-size: var(--fs-md); }
.app-banner__right { display: flex; align-items: center; gap: var(--space-3); }

.boards-main { flex: 1; overflow-y: auto; padding: var(--space-6); }
.hint { color: var(--text-muted); font-size: var(--fs-sm); }

/* ---- Buttons (shared) ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--text-body);
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard);
}
.btn:hover { background: var(--surface-subtle); }
.btn--primary { background: var(--color-brand); border-color: var(--color-brand); color: var(--text-inverse); }
.btn--primary:hover { background: var(--color-brand-hover); }
.btn--danger { background: var(--surface-card); border-color: var(--color-danger); color: var(--color-danger); }
.btn--danger:hover { background: var(--red-20); }
.btn--small { padding: var(--space-1) var(--space-3); font-size: var(--fs-sm); }

/* ---- Board grid ---- */
.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-5);
}
.board-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: box-shadow var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
}
.board-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.board-card__thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border-subtle);
  overflow: hidden;
}
.board-card__thumb img { width: 100%; height: 100%; object-fit: contain; }
.board-card__body { padding: var(--space-3) var(--space-4); }
.board-card__name {
  font-weight: var(--fw-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.board-card__meta { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; }
.board-card__actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); }

.board-card--new {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 2px dashed var(--border-default);
  background: transparent;
  box-shadow: none;
  color: var(--text-muted);
  min-height: 160px;
}
.board-card--new:hover { border-color: var(--color-brand); color: var(--color-brand); background: transparent; transform: none; }
.board-card__plus { font-size: var(--fs-3xl); line-height: 1; }

/* ---- Editor topbar ---- */
.editor-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.editor-topbar__spacer { flex: 1; }
.board-name-input {
  border: none;
  background: transparent;
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  color: var(--text-strong);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  min-width: 120px;
}
.board-name-input:hover, .board-name-input:focus { background: var(--surface-subtle); outline: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  font-size: var(--fs-lg);
  color: var(--text-body);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard);
}
.icon-btn:hover { background: var(--surface-subtle); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn:disabled:hover { background: var(--surface-card); }

/* ---- Editor body / canvas ---- */
.editor-body { position: relative; flex: 1; overflow: hidden; }
.canvas-wrap { position: absolute; inset: 0; }
#board-canvas { display: block; width: 100%; height: 100%; touch-action: none; background: var(--surface-page); }
#text-overlay-host { position: absolute; inset: 0; pointer-events: none; }

/* ---- Floating toolbar ---- */
.toolbar {
  position: absolute;
  top: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2);
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  font-size: var(--fs-lg);
  color: var(--text-body);
  cursor: pointer;
}
.tool-btn:hover { background: var(--surface-subtle); }
.tool-btn.is-active { background: var(--color-brand); color: var(--text-inverse); }
.toolbar__sep { width: 1px; height: 28px; background: var(--border-subtle); margin: 0 var(--space-1); }

/* ---- Style bar (colors / stroke width) ---- */
.style-bar {
  position: absolute;
  top: calc(var(--space-4) + 60px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
}
.style-bar__sep { width: 1px; height: 20px; background: var(--border-subtle); }
.swatches { display: flex; gap: var(--space-1); }
.swatch {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--border-subtle);
  cursor: pointer;
  padding: 0;
}
.swatch.is-active { border-color: var(--color-brand); }
#stroke-width { width: 100px; }

/* ---- Zoom controls ---- */
.zoom-controls {
  position: absolute;
  bottom: var(--space-4);
  right: var(--space-4);
  display: flex;
  gap: var(--space-2);
}

/* ---- Text/sticky inline editor overlay ---- */
.text-editor-box {
  position: absolute;
  pointer-events: auto;
  border: 2px solid var(--color-brand);
  background: transparent;
  resize: none;
  font-family: "Roboto", sans-serif;
  padding: 2px;
  outline: none;
}

/* ---- Toasts ---- */
.toast-host {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 1000;
}
.toast {
  min-width: 220px;
  max-width: 360px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  color: var(--text-inverse);
  background: var(--btech-gray);
  font-size: var(--fs-sm);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--dur-base) var(--ease-standard), transform var(--dur-base) var(--ease-standard);
}
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 640px) {
  .toolbar { flex-wrap: wrap; max-width: calc(100vw - var(--space-4) * 2); justify-content: center; }
  .style-bar { max-width: calc(100vw - var(--space-4) * 2); }
}
