* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
#root {
  min-height: 100vh;
  max-width: 100%;
  margin: 0 auto;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-btn {
  background: none;
  border: none;
  color: #e2e8f0;
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
  font-size: 1.5rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover {
  background: #334155;
}

/* Legendum button */
.legendum-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}
.legendum-linked {
  background: #334155;
  color: #e2e8f0;
}
.legendum-linked:hover {
  background: #475569;
}
.legendum-link {
  background: #3b82f6;
  color: white;
}
.legendum-link:hover {
  background: #2563eb;
}
.legendum-link:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.legendum-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  font-size: 11px;
  font-weight: 700;
}
.legendum-linked.low-credits {
  border: 2px solid #84cc16;
}
.legendum-linked .legendum-icon {
  background: #475569;
}

/* Lists */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #334155;
  cursor: pointer;
  background: #1e293b;
  min-height: 56px;
}
.list-item:active {
  background: #334155;
}
.list-item-content {
  flex: 1;
  min-width: 0;
}
.list-item-title {
  font-weight: 500;
  color: #e2e8f0;
}
.list-item-meta {
  font-size: 14px;
  color: #94a3b8;
  margin-top: 2px;
}

/* Swipe row */
.row-wrap {
  list-style: none;
  margin: 0;
  overflow: hidden;
  border-bottom: 1px solid #334155;
}
.row-slider {
  display: flex;
  width: 100%;
  transition: transform 0.15s ease-out;
  touch-action: pan-y;
}
.row-main {
  flex: 1;
  min-width: 100%;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.row-delete {
  flex-shrink: 0;
  width: 72px;
  padding: 0 8px;
  border: none;
  border-radius: 0;
  background: #dc2626;
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.row-delete:hover {
  background: #ef4444;
}
.row-delete:active {
  background: #b91c1c;
}

/* Screens */
.screen {
  padding-bottom: 24px;
}
.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #334155;
}
.screen-header-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.screen-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}
.back-btn {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #475569;
  background: #334155;
  color: #e2e8f0;
}
.back-btn:hover {
  background: #475569;
}

/* Forms */
.form {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 16px;
}
.input::placeholder {
  color: #64748b;
}
.btn {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: #3b82f6;
  color: white;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-secondary {
  background: #334155;
  color: #e2e8f0;
}
.btn-danger {
  background: #dc2626;
}

/* FAB */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #3b82f6;
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 5;
}
.fab:active {
  background: #2563eb;
}

/* Login */
.login-screen {
  max-width: 400px;
  margin: 0 auto;
  padding: 24px 16px;
  text-align: center;
}
.login-screen h1 {
  font-size: 24px;
  margin-bottom: 8px;
}
.login-screen p {
  color: #94a3b8;
  margin-bottom: 24px;
}
.login-logo {
  width: 96px;
  height: 96px;
  border-radius: 20px;
  margin-bottom: 16px;
}

/* Todo item */
.todo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 48px;
}
.todo-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid #475569;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  color: #3b82f6;
}
.todo-checkbox.checked {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}
.todo-text {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  word-break: break-word;
}
.todo-text.done {
  text-decoration: line-through;
  color: #64748b;
}
.todo-text-edit {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  background: #1e293b;
  color: inherit;
  border: 1px solid #475569;
  border-radius: 4px;
  padding: 2px 4px;
  outline: none;
}

/* Free-form text line */
.freeform-line {
  padding: 4px 16px;
  color: #94a3b8;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 24px;
}

/* Drag handle */
.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  flex-shrink: 0;
  cursor: grab;
  color: #475569;
  touch-action: none;
}
.drag-handle:active {
  cursor: grabbing;
}
.drag-handle svg {
  width: 14px;
  height: 14px;
}

/* Dragging overlay */
.drag-overlay {
  background: #1e293b;
  border: 1px solid #3b82f6;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  opacity: 0.95;
}

/* Inline add input */
.add-todo-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #334155;
  background: #1e293b;
  flex-shrink: 0;
}
.add-todo-bar .input {
  flex: 1;
}
.add-todo-bar .btn {
  flex-shrink: 0;
  padding: 12px 16px;
}

/* Webhook URL copy */
.webhook-url {
  font-size: 12px;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.webhook-url:hover {
  color: #94a3b8;
}
.copied-badge {
  font-size: 11px;
  color: #22c55e;
}

/* Dialog */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.dialog {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #334155;
}
.dialog-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 6px;
}
.dialog-close:hover {
  background: #334155;
  color: #e2e8f0;
}
.dialog-body {
  padding: 20px;
}
.dialog-section {
  margin-bottom: 20px;
}
.dialog-section:last-child {
  margin-bottom: 0;
}
.dialog-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: #94a3b8;
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.dialog-section p {
  font-size: 14px;
  color: #cbd5e1;
  margin: 0 0 8px;
  line-height: 1.5;
}
.dialog-section code {
  background: #0f172a;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: #38bdf8;
}
.dialog-code {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 12px 14px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  color: #e2e8f0;
  overflow-x: auto;
  margin: 0;
  white-space: pre;
  line-height: 1.6;
}

/* Category count */
.cat-count {
  font-size: 14px;
  color: #64748b;
  flex-shrink: 0;
  margin-left: 8px;
}

