:root {
  --bg: #f4f4f4;
  --surface: #ffffff;
  --text: #1f1f1f;
  --muted: #6b6b6b;
  --line: #e3e3e3;
  --track-off: #c4c4c4;
  --track-on: #4a4a4a;
  --thumb-off: #fafafa;
  --thumb-on: #ffffff;
  --danger: #404040;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, "Roboto", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.topbar {
  padding: 18px 20px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
#install {
  background: var(--track-on);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}
#install[hidden] { display: none; }

.list {
  flex: 1;
  padding: 6px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px 20px;
  font-size: 15px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 14px 10px;
}

.card-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.drag-handle {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: var(--track-off);
  font-size: 18px;
  line-height: 1;
  padding: 4px 2px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.card.is-chosen {
  cursor: grabbing;
}
.card.is-ghost {
  opacity: 0.4;
  background: var(--bg);
  border-style: dashed;
}
.card.is-drag {
  box-shadow: 0 10px 24px rgba(0,0,0,0.22);
  transform: scale(1.02);
  cursor: grabbing;
}

.card-text {
  flex: 1;
  min-width: 0;
}

.card-label {
  font-size: 16px;
  font-weight: 500;
  word-break: break-word;
}

.card-time {
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}

/* Android-style switch, no animation */
.switch {
  flex: 0 0 auto;
  width: 52px;
  height: 32px;
  border-radius: 16px;
  background: var(--track-off);
  position: relative;
  cursor: pointer;
  border: none;
  padding: 0;
}
.switch[aria-checked="true"] { background: var(--track-on); }
.switch .thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--thumb-off);
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}
.switch[aria-checked="true"] .thumb {
  left: 23px;
  background: var(--thumb-on);
}
.switch:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.card-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 6px;
}
.card-actions button {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  padding: 8px 4px;
  cursor: pointer;
  border-radius: 8px;
}
.card-actions button:focus-visible { outline: 2px solid var(--text); outline-offset: -2px; }

.history {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.history[hidden] { display: none; }
.history ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}
.history li {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.history .ev-state { font-variant-numeric: tabular-nums; }
.history .empty-hist { font-size: 12px; color: var(--muted); }

.composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.composer input {
  flex: 1;
  font-size: 15px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}
.composer input:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.composer button {
  background: var(--track-on);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 16px;
  font-size: 15px;
  cursor: pointer;
}

.footer {
  padding: 10px 16px 16px;
}
.backup {
  display: flex;
  gap: 8px;
}
.backup button {
  flex: 1;
  background: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.credits {
  margin: 12px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.credits a { color: var(--muted); }
