:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e1d8;
  --accent: #111827;
  --accent-soft: #ede9dd;
  --danger: #b91c1c;
  --success: #166534;
  --shadow: 0 20px 60px rgba(17, 24, 39, .08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

.site-header {
  min-height: 72px;
  padding: 18px clamp(18px, 4vw, 54px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .75);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -.02em;
}

.brand.compact {
  font-size: 15px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-family: Arial, sans-serif;
}

main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  padding: clamp(56px, 10vw, 112px) 0 56px;
}

.eyebrow,
.small-muted,
.section-heading {
  font-family: Arial, sans-serif;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.hero h1 {
  max-width: 880px;
  margin: 14px 0 18px;
  font-size: clamp(38px, 7vw, 72px);
  line-height: .95;
  letter-spacing: -.055em;
}

.hero p {
  max-width: 720px;
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.5;
  color: #4b5563;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 30px;
}

.button,
.tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-weight: 700;
  font-size: 14px;
}

.button:hover,
.tool:hover {
  border-color: #c7c0b3;
}

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

.button.subtle {
  background: transparent;
}

.button.full {
  width: 100%;
}

.button.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 28px;
}

.info-card,
.create-panel,
.setup-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.info-card h2,
.create-panel h2 {
  margin-top: 0;
  font-size: 24px;
  letter-spacing: -.035em;
}

.info-card p,
.create-panel p {
  color: #4b5563;
  line-height: 1.55;
}

.create-panel {
  margin: 26px 0 80px;
  display: grid;
  gap: 18px;
}

.create-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.create-form label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-family: Arial, sans-serif;
  font-weight: 700;
  font-size: 13px;
}

.create-form input,
.dialog input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0 14px;
  background: #fff;
}

.error-box,
.error {
  color: var(--danger);
}

.success {
  color: var(--success);
  font-weight: 700;
}

.danger {
  color: var(--danger);
  font-weight: 700;
}

.setup-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.setup-card {
  width: min(680px, calc(100% - 32px));
}

.setup-card pre {
  white-space: pre-wrap;
  background: #111827;
  color: #f9fafb;
  padding: 18px;
  border-radius: 16px;
  overflow: auto;
}

.dialog {
  width: min(560px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
}

.dialog::backdrop {
  background: rgba(17, 24, 39, .45);
}

.dialog menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
  margin: 18px 0 0;
}

.board-body {
  overflow: hidden;
}

.whiteboard-app {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100vh;
}

.sidebar {
  padding: 20px;
  background: #fffaf0;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.board-title-block {
  margin: 28px 0 16px;
}

.board-title-block h1 {
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: -.04em;
  margin: 8px 0 0;
}

.sidebar-section {
  margin-top: 26px;
}

.page-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.page-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 16px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
}

.page-item.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.page-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-rename {
  border: 0;
  background: transparent;
  font-family: Arial, sans-serif;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

.sync-status {
  margin-top: 18px;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: #4b5563;
  font-family: Arial, sans-serif;
  font-size: 12px;
}

.paste-hint {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed #c7c0b3;
  border-radius: 16px;
  background: rgba(255, 255, 255, .58);
  color: #4b5563;
  font-family: Arial, sans-serif;
  font-size: 12px;
  line-height: 1.45;
}

.workspace {
  width: 100%;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  margin: 0;
}

.toolbar {
  min-height: 72px;
  padding: 14px 18px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(12px);
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tool-group label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: Arial, sans-serif;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tool-group input[type="number"] {
  width: 72px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
}

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

.canvas-shell {
  position: relative;
  margin: 18px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background:
    linear-gradient(rgba(31,41,55,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31,41,55,.045) 1px, transparent 1px),
    #fff;
  background-size: 32px 32px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

#boardCanvas {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

#textEditorLayer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.text-input {
  position: absolute;
  z-index: 10;
  min-width: 220px;
  min-height: 56px;
  padding: 10px 12px;
  border: 2px solid var(--accent);
  border-radius: 10px;
  resize: both;
  overflow: auto;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 14px 34px rgba(17, 24, 39, .18);
  pointer-events: auto;
  outline: none;
  line-height: 1.25;
}

.text-input::placeholder {
  color: #9ca3af;
  font-family: Arial, sans-serif;
  font-size: 12px;
}

@media (max-width: 900px) {
  .panel-grid,
  .whiteboard-app {
    grid-template-columns: 1fr;
  }

  .whiteboard-app {
    height: auto;
    min-height: 100vh;
  }

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

  .workspace {
    height: calc(100vh - 280px);
    min-height: 540px;
  }

  .create-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .site-header {
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
  }

  .toolbar {
    align-items: flex-start;
  }

  .hero h1 {
    font-size: 40px;
  }
}

/* Mobile and tablet improvements */
html,
body {
  height: 100%;
  overscroll-behavior: none;
}

.board-body {
  height: 100dvh;
  min-height: 100dvh;
  position: fixed;
  inset: 0;
  width: 100%;
}

.whiteboard-app {
  height: 100dvh;
  min-height: 0;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

button,
.button,
.tool,
.page-item,
.file-button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (max-width: 900px) {
  .board-body {
    overflow: hidden;
  }

  .whiteboard-app {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh;
    min-height: 0;
  }

  .sidebar {
    padding: 10px 12px;
    max-height: 190px;
    overflow-y: auto;
  }

  .sidebar .brand {
    display: none;
  }

  .board-title-block {
    margin: 0 0 8px;
  }

  .board-title-block h1 {
    font-size: 18px;
    line-height: 1.15;
    margin-top: 3px;
  }

  .sidebar > .button {
    width: auto;
    min-height: 38px;
    margin-right: 6px;
    margin-bottom: 6px;
    padding: 0 12px;
    font-size: 12px;
  }

  .sidebar-section {
    margin-top: 8px;
  }

  .page-list {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .page-item {
    flex: 0 0 auto;
    width: auto;
    max-width: 210px;
    min-height: 38px;
    border-radius: 999px;
    padding: 8px 10px;
  }

  .sync-status,
  .paste-hint {
    display: none;
  }

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

  .toolbar {
    min-height: 0;
    padding: 8px 10px;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }

  .tool-group {
    flex: 0 0 auto;
    gap: 6px;
    flex-wrap: nowrap;
    scroll-snap-align: start;
  }

  .button,
  .tool {
    min-height: 42px;
    padding: 0 13px;
    font-size: 13px;
  }

  .button.small {
    min-height: 40px;
    padding: 0 11px;
    white-space: nowrap;
  }

  .tool-group label {
    white-space: nowrap;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 10px;
  }

  .tool-group input[type="range"] {
    width: 86px;
  }

  .tool-group input[type="number"] {
    width: 64px;
    min-height: 30px;
  }

  .canvas-shell {
    margin: 8px;
    border-radius: 18px;
    min-height: 0;
  }

  #boardCanvas {
    touch-action: none;
  }

  .text-input {
    min-width: min(260px, calc(100% - 24px));
    max-width: calc(100% - 24px);
    min-height: 72px;
    resize: vertical;
    border-radius: 14px;
    font-size: 18px;
  }
}

@media (max-width: 520px) {
  .sidebar {
    max-height: 160px;
  }

  .board-title-block h1 {
    font-size: 16px;
  }

  .section-heading,
  .small-muted {
    font-size: 10px;
  }

  .toolbar {
    padding: 7px 8px;
  }

  .button,
  .tool {
    min-height: 40px;
    padding: 0 11px;
    font-size: 12px;
  }

  .canvas-shell {
    margin: 6px;
    border-radius: 16px;
  }
}

/* Existing board list and delete controls */
.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.section-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.success-box,
.notice-box,
.warning-box,
.empty-state {
  border-radius: 18px;
  padding: 14px 16px;
  font-family: Arial, sans-serif;
  font-size: 13px;
  line-height: 1.45;
}

.success-box {
  background: #ecfdf5;
  color: var(--success);
  border: 1px solid #bbf7d0;
  font-weight: 700;
}

.notice-box {
  background: #eff6ff;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
}

.warning-box {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
}

.empty-state {
  background: #f9fafb;
  color: var(--muted);
  border: 1px dashed var(--line);
}

.board-list {
  display: grid;
  gap: 14px;
}

.board-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
}

.board-card h3 {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: -.03em;
}

.board-card p {
  margin: 0;
}

.board-meta,
.board-key {
  font-family: Arial, sans-serif;
  font-size: 13px;
  color: var(--muted);
}

.board-key {
  margin-top: 6px !important;
}

.board-key code,
.notice-box code,
.warning-box code {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 2px 6px;
}

.board-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.delete-board-form {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin: 0;
}

.pin-input {
  width: 130px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  font-family: Arial, sans-serif;
  font-size: 12px;
}

.danger-button {
  color: var(--danger);
  border-color: #fecaca;
  background: #fff5f5;
}

.danger-button:hover {
  border-color: #fca5a5;
  background: #fee2e2;
}

@media (max-width: 760px) {
  .section-head-row,
  .board-card {
    grid-template-columns: 1fr;
  }

  .board-card-actions {
    justify-content: flex-start;
  }

  .delete-board-form {
    width: 100%;
    flex-wrap: wrap;
  }

  .pin-input {
    flex: 1 1 160px;
  }
}

@media (max-width: 640px) {
  .header-actions {
    width: 100%;
  }

  .header-actions .button {
    flex: 1 1 auto;
  }

  .board-card-actions .button,
  .delete-board-form .button {
    flex: 1 1 auto;
  }
}
