*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #111827;
  --surface: #1f2937;
  --text: #f9fafb;
  --text-muted: #9ca3af;
  --accent: #3b82f6;
  --danger: #ef4444;
  --success: #22c55e;
  --border: #374151;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.header-actions {
  display: flex;
  gap: 8px;
}

#archive-all-btn {
  background: var(--danger);
  color: var(--text);
  border: none;
  border-radius: 6px;
  padding: 0 16px;
  font-size: 0.875rem;
  cursor: pointer;
  min-height: 48px;
  min-width: 48px;
}

#archive-btn {
  background: var(--accent);
  color: var(--text);
  border: none;
  border-radius: 6px;
  padding: 0 16px;
  font-size: 0.875rem;
  cursor: pointer;
  min-height: 48px;
  min-width: 48px;
}

#add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

#add-input {
  flex: 1;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 12px;
  font-size: 1rem;
  min-height: 48px;
}

#add-input::placeholder {
  color: var(--text-muted);
}

#add-form button[type="submit"] {
  background: var(--accent);
  color: var(--text);
  border: none;
  border-radius: 6px;
  padding: 0 20px;
  font-size: 1rem;
  cursor: pointer;
  min-height: 48px;
  min-width: 48px;
}

#counter-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.counter-card {
  background: var(--surface);
  border-radius: 10px;
  padding: 12px 16px;
}

.counter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.counter-name {
  font-weight: 700;
  font-size: 1rem;
}

.delete-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 1rem;
  cursor: pointer;
  min-height: 48px;
  min-width: 48px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.counter-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.decrement-btn,
.increment-btn {
  min-width: 64px;
  min-height: 64px;
  border: none;
  border-radius: 8px;
  font-size: 1.75rem;
  cursor: pointer;
  flex: 1;
}

.decrement-btn {
  background: var(--border);
  color: var(--text);
}

.increment-btn {
  background: var(--success);
  color: var(--text);
}

.counter-value {
  font-size: 2.5rem;
  font-weight: 700;
  text-align: center;
  flex: 1;
  line-height: 1;
  cursor: pointer;
}

.counter-value-input {
  font-size: 2.5rem;
  font-weight: 700;
  font-family: inherit;
  text-align: center;
  flex: 1;
  line-height: 1;
  background: transparent;
  color: var(--text);
  border: none;
  outline: none;
  width: 0;
  min-width: 0;
  appearance: none;
}

.counter-value-input::-webkit-inner-spin-button,
.counter-value-input::-webkit-outer-spin-button {
  display: none;
}

/* Archive modal */

dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  width: min(480px, calc(100vw - 32px));
  max-height: 80vh;
}

dialog[open] {
  display: flex;
  flex-direction: column;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 700;
}

#archive-close {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 1rem;
  cursor: pointer;
  min-height: 48px;
  min-width: 48px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#archive-close:hover {
  color: var(--text);
}

#archive-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}

.archive-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 24px 16px;
  font-size: 0.875rem;
}

.archive-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.archive-name {
  flex: 1;
  font-weight: 600;
}

.archive-count {
  color: var(--text-muted);
  font-size: 1.25rem;
  font-weight: 700;
  min-width: 2ch;
  text-align: right;
}

.restore-btn {
  background: var(--border);
  color: var(--text);
  border: none;
  border-radius: 6px;
  padding: 0 12px;
  font-size: 0.875rem;
  cursor: pointer;
  min-height: 48px;
  min-width: 48px;
}

#archive-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

.delete-all-btn {
  background: var(--danger);
  color: var(--text);
  border: none;
  border-radius: 6px;
  padding: 0 16px;
  font-size: 0.875rem;
  cursor: pointer;
  min-height: 48px;
  min-width: 48px;
}
