:root {
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f2430;
  --text: #eef2ff;
  --muted: #9aa4b2;
  --accent: #7c9cff;
  --border: #2b3242;
  --todo: #1e8e5a;
  --note: #8b6bdb;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
.app {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
}
.topbar, .panel-head, .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-badge {
  color: var(--muted);
  font-size: 13px;
}
.hidden {
  display: none !important;
}
.topbar h1, .panel-head h2 {
  margin: 0;
}
.topbar p, .statusbar, .meta, .empty {
  color: var(--muted);
}
button {
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}
button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
button:disabled {
  opacity: .6;
  cursor: wait;
}
input[type="search"],
.login-card input {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15,17,21,.88);
  backdrop-filter: blur(8px);
}
.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
}
.login-card h2,
.login-card p {
  margin: 0;
}
.login-card p,
.login-card label span {
  color: var(--muted);
}
.login-card label {
  display: grid;
  gap: 6px;
}
.login-error {
  min-height: 18px;
  color: #ff8f8f;
  font-size: 13px;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  flex-wrap: wrap;
}
.tabs {
  display: flex;
  gap: 8px;
}
.tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.tab.active {
  background: var(--accent);
  border-color: var(--accent);
}
.search-wrap {
  flex: 1;
}
.review-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
.statusbar {
  margin: 0 0 20px;
}
.grid {
  display: grid;
  gap: 20px;
}
.grid-main {
  grid-template-columns: minmax(0, 1fr) 360px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}
.list {
  display: grid;
  gap: 12px;
}
.bucket-lists {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 14px;
  padding-bottom: 20px;
  align-items: start;
}
.bucket-section {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  min-width: 0;
  width: 100%;
}
.bucket-section h3 {
  margin: 0 0 12px 0;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
}
.card:hover {
  border-color: var(--muted);
}
.card.active {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.card.review {
  border-color: #ffb84d;
}
.card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}
.card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.card p a,
.detail-links a {
  color: #8fc3ff;
  text-decoration: underline;
}
.badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}
.link-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge, .pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
}
.badge.todo { background: rgba(30,142,90,.18); color: #78e0aa; }
.badge.note { background: rgba(139,107,219,.18); color: #c9b8ff; }
.badge.bucket { background: rgba(124,156,255,.14); color: #bcd0ff; }
.badge.deadline { background: rgba(255,184,77,.14); color: #ffd089; }
.detail-panel {
  position: sticky;
  top: 24px;
}
.detail.hidden {
  display: none;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}
.actions button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.empty {
  padding: 12px 0;
  font-size: 14px;
}
@media (max-width: 1100px) {
  .grid-main { grid-template-columns: 1fr; }
  .detail-panel { position: static; }
}
.action-group {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}
.action-group label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.action-group select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  width: 100%;
}
.action-group button.active {
  background: var(--accent);
  color: white;
}
.edit-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  padding: 4px;
  border-radius: 4px;
  font-family: inherit;
  margin-bottom: 8px;
}
.edit-input:hover {
  border-color: var(--border);
}
.edit-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel-2);
}
.title-input {
  font-size: 18px;
  font-weight: bold;
}
.body-input {
  min-height: 120px;
  resize: vertical;
  font-size: 15px;
  line-height: 1.5;
}
.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
button.danger {
  background: #cf4b4b;
}
button.danger:hover {
  background: #ff5e5e;
}
.card.done {
  opacity: 0.5;
  text-decoration: line-through;
  filter: grayscale(1);
}
.card.done:hover {
  opacity: 0.8;
  filter: none;
}

/* Trello-style board */
.grid-main {
  display: block;
}
.grid-main > .panel:first-child {
  min-width: 0;
}
.detail-panel {
  display: none;
}
.bucket-lists {
  display: flex;
  grid-template-columns: none;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 14px -16px -16px;
  padding: 0 16px 18px;
  align-items: flex-start;
  scroll-snap-type: x proximity;
}
.bucket-section {
  flex: 0 0 320px;
  width: 320px;
  max-height: calc(100vh - 230px);
  display: flex;
  flex-direction: column;
  scroll-snap-align: start;
}
.bucket-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -12px -12px 10px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  border-radius: 14px 14px 0 0;
  background: rgba(31,36,48,.96);
}
.bucket-head h3 {
  margin: 0;
}
.bucket-section .list {
  overflow-y: auto;
  padding-right: 2px;
}
.card {
  cursor: default;
}
.card-summary {
  cursor: pointer;
}
.card.done {
  opacity: .64;
}
.card.expanded {
  border-color: var(--accent);
  box-shadow: 0 14px 40px rgba(0,0,0,.22);
}
.card-editor {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.card-editor label,
.inline-controls label {
  display: grid;
  gap: 5px;
}
.card-editor label span,
.inline-controls label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.inline-title {
  font-size: 16px;
  font-weight: 800;
}
.inline-body {
  min-height: 110px;
  resize: vertical;
}
.inline-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.inline-controls select,
.inline-controls input,
.card-editor input,
.card-editor textarea {
  width: 100%;
}
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.inline-actions button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.inline-actions .save-state {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}
@media (max-width: 700px) {
  .app { padding: 14px; }
  .bucket-lists { margin-left: -14px; margin-right: -14px; padding-left: 14px; padding-right: 14px; }
  .bucket-section { flex-basis: min(86vw, 340px); width: min(86vw, 340px); }
}

/* Wrap long titles and labels inside Trello cards/columns */
.bucket-head h3,
.card h3,
.inline-title,
.card-editor input,
.card-editor textarea {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}
.card h3 {
  line-height: 1.25;
  white-space: normal;
}
.bucket-head h3 {
  flex: 1;
  line-height: 1.2;
  white-space: normal;
}
.card-summary,
.card-editor,
.meta,
.badges {
  min-width: 0;
}

/* Mobile gravity snap: columns settle into place after horizontal swipes */
.bucket-lists {
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 16px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.bucket-section {
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
@media (max-width: 700px) {
  .bucket-lists {
    scroll-padding-inline: 14px;
  }
  .bucket-section {
    scroll-snap-align: center;
  }
}
