:root {
  --bg: #141218;
  --surface: #1d1b20;
  --surface-hi: #25232b;
  --surface-hover: #2f2c37;
  --on-surface: #e6e0e9;
  --on-surface-variant: #cac4d0;
  --primary: #c3b4ff;
  --on-primary: #37225c;
  --primary-container: #4c3a80;
  --on-primary-container: #e6deff;
  --outline: #48454e;
  --completed: #8fd6a8;
  --dropped: #f2a0a0;
  --error: #ffb4ab;
  --on-error: #690005;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--on-surface);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* login screen */
#login-screen {
  max-width: 380px;
  margin: 15vh auto 0;
  padding: 36px 32px;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 16px;
}
#login-screen h1 {
  font-size: 21px;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
#login-screen p {
  color: var(--on-surface-variant);
  font-size: 14px;
  margin: 0 0 20px;
}
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--on-surface-variant);
  margin: 14px 0 6px;
}
input[type="text"], input[type="password"], input[type="number"] {
  width: 100%;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid var(--outline);
  background: var(--bg);
  color: var(--on-surface);
  font-size: 15px;
  font-family: inherit;
}
input:focus { outline: none; border-color: var(--primary); }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}
.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
  padding: 11px 22px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--outline);
  color: var(--on-surface);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}
.btn-outline:hover { background: var(--surface-hover); }
.btn-icon {
  background: var(--surface-hi);
  color: var(--on-surface-variant);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--on-surface); }
#login-error {
  color: var(--error);
  font-size: 13px;
  margin-top: 12px;
  min-height: 16px;
}

/* app shell */
#app {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 100px;
}
header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
header.topbar h1 {
  font-size: 26px;
  margin: 0;
  font-weight: 700;
  color: var(--on-surface);
}
#status-line {
  font-size: 12px;
  color: var(--on-surface-variant);
  margin: 4px 0 24px;
}

.cat-select-wrap {
  position: relative;
}
.field-select-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid var(--outline);
  background: var(--bg);
  color: var(--on-surface);
  font-size: 15px;
  font-family: inherit;
}
.field-select-btn:hover { border-color: var(--primary); }
.cat-select-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  padding: 6px 8px;
  border-radius: 8px;
  margin-left: -8px;
}
.cat-select-btn:hover {
  background: var(--surface-hi);
}
.cat-select-arrow {
  font-size: 18px;
  color: var(--on-surface);
  line-height: 1;
  display: inline-flex;
}
.cat-select-arrow svg { display: block; }
.cat-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 250px;
  max-height: 340px;
  overflow-y: auto;
  background: var(--surface-hi);
  border: 1px solid var(--outline);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  z-index: 5;
}
.cat-select-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  background: none;
  color: var(--on-surface);
  font-size: 14px;
  font-weight: 500;
}
.cat-select-item:hover {
  background: var(--surface-hover);
}
.cat-select-item.selected {
  color: var(--primary);
  background: var(--primary-container);
  font-weight: 700;
}
.cat-select-item .count {
  margin-left: auto;
  color: var(--on-surface-variant);
  font-weight: 400;
  font-size: 13px;
}

.entry-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.entry-card {
  background: var(--surface-hi);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.entry-info { flex: 1; min-width: 0; }
.entry-title {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.entry-sub {
  font-size: 12.5px;
  color: var(--on-surface-variant);
  margin-top: 2px;
}
.entry-sub svg { vertical-align: -2px; margin: 0 1px; }
.progress-track {
  height: 3px;
  border-radius: 2px;
  background: var(--outline);
  margin-top: 8px;
  overflow: hidden;
  max-width: 220px;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
}
.entry-card.completed .progress-fill { background: var(--completed); }
.entry-card.dropped .progress-fill { background: var(--dropped); }
.entry-status-icon { flex: 0 0 auto; display: flex; }
.entry-card.completed .entry-status-icon { color: var(--completed); }
.entry-card.dropped .entry-status-icon { color: var(--dropped); }

.inc-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--surface-hi);
  color: var(--primary);
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.inc-btn:hover { background: var(--primary-container); }

.fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 26px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(195,180,255,0.35);
}
.fab:hover { filter: brightness(1.06); }

.empty-state {
  color: var(--on-surface-variant);
  text-align: center;
  padding: 48px 20px;
  font-size: 14px;
}

/* modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4,10,16,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 16px;
  padding: 26px;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal h2 {
  margin: 0 0 18px;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
.field-row {
  display: flex;
  gap: 10px;
}
.field-row > div { flex: 1; }

.cat-manage-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--outline);
}
.cat-manage-row .cat-name { flex: 1; font-size: 14px; font-weight: 500; }
.toggle-btn {
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.35;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--on-surface);
}
.toggle-btn:hover { background: var(--surface-hi); }
.toggle-btn.active { opacity: 1; }
.toggle-btn.active.done { color: var(--completed); }
.toggle-btn.active.drop { color: var(--dropped); }
.icon-btn-sm {
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-surface-variant);
  width: 28px;
  height: 28px;
  border-radius: 8px;
}
.icon-btn-sm:hover { background: var(--surface-hi); color: var(--on-surface); }

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-hi);
  border: 1px solid var(--outline);
  color: var(--on-surface);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  transition: opacity 0.3s;
  opacity: 0;
  pointer-events: none;
}
#toast.show { opacity: 1; }
