:root {
  --ink: #151a23;
  --muted: #5b6575;
  --line: #d8dee8;
  --panel: #ffffff;
  --paper: #f4f7fb;
  --accent: #2563eb;
  --teal: #0f766e;
  --amber: #b45309;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); overflow: hidden; }
button, input, textarea { font: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--ink); }

.hidden { display: none !important; }
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 15%, rgba(20, 184, 166, .18), transparent 28%),
    radial-gradient(circle at 80% 70%, rgba(245, 158, 11, .18), transparent 25%),
    linear-gradient(135deg, #eef6ff, #f8fafc 48%, #fff7ed);
}
.login-panel {
  width: min(390px, calc(100vw - 32px));
  padding: 30px;
  border: 1px solid rgba(37, 99, 235, .16);
  border-radius: 8px;
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 28px 80px rgba(15, 23, 42, .18);
  backdrop-filter: blur(14px);
}
.login-logo { width: 58px; height: 58px; }
.login-panel h1 { margin: 12px 0 24px; font-size: 30px; letter-spacing: 0; }
.login-panel label { display: grid; gap: 7px; margin: 14px 0; font-weight: 700; color: #334155; }
.login-panel input {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
}
.login-panel button {
  width: 100%;
  height: 44px;
  margin-top: 12px;
  border: 0;
  border-radius: 6px;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, #0f766e, #2563eb);
}
.error { min-height: 20px; color: #be123c; font-weight: 700; }

.app { height: 100vh; display: grid; grid-template-rows: 64px 1fr; grid-template-columns: 58px 1fr; }
.topbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 230px minmax(220px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 40px; height: 40px; }
.brand div { display: grid; line-height: 1.1; }
.brand strong { font-size: 18px; }
.brand span { color: var(--muted); font-size: 12px; margin-top: 4px; }
.search-wrap {
  position: relative;
}
.search-wrap input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 44px 0 14px;
  background: #f8fafc;
}
.clear-search {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 6px;
  border-color: transparent;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
}
.clear-search:hover {
  background: #e2e8f0;
  color: #111827;
}
.actions { display: flex; gap: 8px; }
.actions button, .card-tools button {
  min-width: 38px;
  height: 36px;
  border-radius: 6px;
  font-weight: 800;
}
#newCardBtn { background: #111827; color: #fff; border-color: #111827; font-size: 22px; line-height: 1; }

.rail {
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 10px;
  border-right: 1px solid var(--line);
  background: #fff;
  z-index: 5;
}
.swatch { width: 36px; height: 36px; border-radius: 18px; border: 3px solid transparent; }
.swatch.active { border-color: #111827; }
.swatch.amber { background: #fef3c7; }
.swatch.teal { background: #ccfbf1; }
.swatch.blue { background: #dbeafe; }
.swatch.rose { background: #ffe4e6; }
.swatch.graphite { background: #e5e7eb; }

.board {
  position: relative;
  grid-row: 2;
  overflow: auto;
  min-width: 0;
  background-color: #f4f7fb;
  background-image:
    linear-gradient(#e4eaf3 1px, transparent 1px),
    linear-gradient(90deg, #e4eaf3 1px, transparent 1px);
  background-size: 28px 28px;
}
.empty {
  position: fixed;
  inset: 64px 0 0 58px;
  display: grid;
  place-items: center;
  align-content: center;
  color: var(--muted);
  pointer-events: none;
}
.empty img { width: 80px; opacity: .45; }
.empty h2 { margin: 18px 0 4px; color: var(--ink); }
.empty p { margin: 0; }

.card {
  position: absolute;
  min-width: 260px;
  min-height: 154px;
  border: 1px solid rgba(15, 23, 42, .18);
  border-radius: 8px;
  background: #fef3c7;
  box-shadow: 0 18px 45px rgba(15, 23, 42, .18);
  resize: both;
  overflow: auto;
}
.card[data-color="teal"] { background: #ccfbf1; }
.card[data-color="blue"] { background: #dbeafe; }
.card[data-color="rose"] { background: #ffe4e6; }
.card[data-color="graphite"] { background: #e5e7eb; }
.card.pinned { outline: 3px solid rgba(37, 99, 235, .35); }
.card.minimized { height: 54px !important; min-height: 54px; resize: none; overflow: visible; }
.card.minimized .card-body, .card.minimized .card-foot { display: none; }
.card.minimized .card-head { cursor: default; }
.card.minimized .card-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card.minimized .card-tools button:not([data-action="minimize"]) { display: none; }
.card.minimized .card-tools button[data-action="minimize"] {
  min-width: 52px;
  color: #fff;
  background: #111827;
  border-color: #111827;
}
.card-head {
  height: 48px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid rgba(15, 23, 42, .12);
  cursor: grab;
}
.card-title {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  font-weight: 850;
  color: #111827;
  outline: none;
}
.card-tools { display: flex; gap: 4px; }
.card-tools button {
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  background: rgba(255, 255, 255, .62);
  border-color: rgba(15, 23, 42, .18);
  font-size: 11px;
}
.card-body {
  width: 100%;
  height: calc(100% - 84px);
  min-height: 70px;
  padding: 12px;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  line-height: 1.45;
  color: #1f2937;
}
.card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px 8px;
  color: #334155;
  font-size: 12px;
}
.ai-pill {
  white-space: nowrap;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, .64);
  font-weight: 800;
}
.tags { display: flex; flex-wrap: wrap; gap: 4px; overflow: hidden; }
.tag {
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(15, 23, 42, .12);
}
.summary-tip {
  display: none;
  position: absolute;
  left: 10px;
  bottom: 34px;
  max-width: min(340px, calc(100% - 20px));
  padding: 10px;
  border-radius: 7px;
  color: #fff;
  background: rgba(17, 24, 39, .94);
  font-size: 13px;
  line-height: 1.35;
  z-index: 4;
}
.card.show-summary .summary-tip:not(:empty) { display: block; }
.card.minimized .summary-tip {
  top: 58px;
  bottom: auto;
  left: 0;
  max-width: 292px;
}

@media (max-width: 720px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
  .topbar { grid-template-columns: 1fr; gap: 10px; }
  .rail { grid-row: 2; flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); }
  .board { grid-row: 3; min-height: calc(100vh - 170px); }
  .card { min-width: 240px; }
}
