:root {
  --bg: #0f172a;
  --bg-elevated: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --danger: #f87171;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.view[hidden] { display: none !important; }

.offline-banner {
  background: #7c2d12;
  color: #fed7aa;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.875rem;
}

/* Login */
#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  text-align: center;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  color: var(--text);
  font-size: 1rem;
}

button {
  cursor: pointer;
  font: inherit;
}

.login-card button[type="submit"] {
  background: var(--accent);
  color: #0f172a;
  border: none;
  border-radius: 8px;
  padding: 0.65rem;
  font-weight: 600;
}

.error {
  color: var(--danger);
  font-size: 0.875rem;
  margin: 0;
}

/* App layout */
#app-view {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 1rem;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.icon-btn {
  background: var(--accent);
  color: #0f172a;
  border: none;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  font-size: 1.1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.list-group h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.list-nav {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 4px;
}

.list-nav li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.list-nav li .list-name { flex: 1; }

.list-nav li:hover { background: rgba(255, 255, 255, 0.05); }
.list-nav li.active { background: var(--accent); color: #0f172a; font-weight: 600; }

.new-list-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: auto;
}

.new-list-form input[type="text"] {
  flex: 1;
  min-width: 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  width: 100%;
}

.new-list-form button {
  background: var(--accent);
  color: #0f172a;
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
}

.sync-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0;
}

.link-btn.danger { color: var(--danger); }

.content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  margin-top: 4rem;
}

.list-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.list-view-header h2 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.back-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.75rem;
  line-height: 1;
  padding: 0 0.25rem;
  flex-shrink: 0;
}

.new-todo-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.new-todo-form input {
  flex: 1;
}

.new-todo-form button {
  background: var(--accent);
  color: #0f172a;
  border: none;
  border-radius: 8px;
  padding: 0 1rem;
  font-weight: 600;
}

.todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
}

.todo-item .todo-text { flex: 1; }

.todo-item.completed .todo-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.todo-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.completed-heading {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 1.5rem 0 0.5rem;
}

.drag-handle {
  flex-shrink: 0;
  cursor: grab;
  color: var(--text-muted);
  touch-action: none;
  padding: 0 0.15rem;
  font-size: 1rem;
  line-height: 1;
  user-select: none;
}

.sortable-ghost {
  opacity: 0.4;
}

.sortable-chosen {
  box-shadow: 0 0 0 2px var(--accent);
}

@media (max-width: 720px) {
  #app-view { flex-direction: column; }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .content { padding: 1rem; }

  /* Nur ein Screen gleichzeitig: Übersicht ODER Listeninhalt */
  .sidebar { display: flex; }
  .content { display: none; }
  #app-view.mobile-detail .sidebar { display: none; }
  #app-view.mobile-detail .content { display: block; }
  .back-btn { display: inline-flex; align-items: center; }
}
