/* =========================================================
   Taskstamp — design tokens
   Signature idea: tasks read like stamped index-card stubs.
   Priority shows as a small punch-tab; finished tasks get a
   rotated ink-stamp mark instead of just being greyed out.
   ========================================================= */

:root,
[data-theme="light"] {
  --bg: #F2F6F4;
  --surface: #FFFFFF;
  --surface-2: #E6EEE9;
  --border: #D7E2DC;
  --text: #16241F;
  --text-muted: #5B6F65;
  --accent: #1F4A40;
  --accent-soft: #DCEEE7;
  --mint: #2E9C7E;
  --amber: #B9791F;
  --amber-soft: #F6E7CE;
  --danger: #A6412F;
  --danger-soft: #F5DCD6;
  --shadow: 0 1px 2px rgba(22, 36, 31, 0.06), 0 6px 20px rgba(22, 36, 31, 0.06);
}

[data-theme="dark"] {
  --bg: #0E1915;
  --surface: #15221D;
  --surface-2: #1D2E27;
  --border: #28392F;
  --text: #E7F1EC;
  --text-muted: #93A99E;
  --accent: #6FE7C9;
  --accent-soft: #1D3A32;
  --mint: #6FE7C9;
  --amber: #E5AE64;
  --amber-soft: #35301F;
  --danger: #E38B76;
  --danger-soft: #3A241F;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win over any `display` set by a
   class on the same element (e.g. `.modal`, `.auth-form` both set
   `display: flex`, which would otherwise override the browser's
   default `[hidden] { display: none }` rule). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  transition: background 0.25s ease, color 0.25s ease;
}

body { -webkit-font-smoothing: antialiased; }

h1, h2, h3, .brand-name { font-family: 'Fraunces', Georgia, serif; }

button, input, textarea, select { font-family: inherit; color: inherit; }

.mono { font-family: 'IBM Plex Mono', monospace; }

/* ---------- shared bits ---------- */
.btn {
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1.1rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--bg); }
[data-theme="dark"] .btn-primary { color: #08130F; }
.btn-primary:hover { opacity: 0.92; }
.btn-block { width: 100%; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

.link-btn {
  background: none;
  border: none;
  color: var(--mint);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0;
  align-self: flex-start;
}

.field { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.field input {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 0.95rem;
  color: var(--text);
}
.field small { color: var(--text-muted); font-weight: 400; }

/* ---------- auth screen ---------- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 15% 10%, var(--accent-soft), transparent 45%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1.5rem; }
.brand-name { font-size: 1.3rem; font-weight: 600; letter-spacing: -0.01em; }

.auth-tabs { display: flex; gap: 0.4rem; background: var(--surface-2); padding: 0.3rem; border-radius: 10px; margin-bottom: 1.4rem; }
.auth-tab {
  flex: 1; border: none; background: none; padding: 0.55rem; border-radius: 8px;
  font-weight: 600; font-size: 0.88rem; color: var(--text-muted); cursor: pointer;
}
.auth-tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-hint { font-size: 0.78rem; color: var(--text-muted); text-align: center; margin: 0.6rem 0 0; }
.auth-error {
  background: var(--danger-soft); color: var(--danger);
  border-radius: 8px; padding: 0.6rem 0.8rem; font-size: 0.85rem; margin-bottom: 1rem;
}

/* ---------- app shell ---------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
.header-actions { display: flex; align-items: center; gap: 0.5rem; position: relative; }

.user-btn { border-radius: 50%; background: var(--accent); color: var(--bg); font-weight: 700; border: none; }
[data-theme="dark"] .user-btn { color: #08130F; }

.user-menu { position: relative; }
.user-dropdown {
  position: absolute; right: 0; top: 46px;
  width: 240px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 0.6rem; z-index: 30;
}
.user-dropdown-name { margin: 0.2rem 0.4rem 0; font-weight: 600; }
.user-dropdown-email { margin: 0 0.4rem 0.6rem; font-size: 0.8rem; color: var(--text-muted); }
.dropdown-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 0.55rem 0.4rem; border-radius: 8px; font-size: 0.88rem; cursor: pointer; color: var(--text);
}
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item-danger { color: var(--danger); }

.app-main { max-width: 720px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* ---------- composer ---------- */
.composer { margin-bottom: 1.4rem; }
.task-form {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 1rem; display: flex; flex-direction: column; gap: 0.6rem; box-shadow: var(--shadow);
}
#task-title {
  border: none; background: none; font-size: 1.05rem; padding: 0.3rem 0.2rem;
  border-bottom: 1px dashed var(--border);
}
#task-title:focus { outline: none; border-bottom-color: var(--mint); }
.composer-details { display: flex; flex-direction: column; gap: 0.7rem; }
.composer-details textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem; resize: vertical; background: var(--bg);
}
.composer-row { display: flex; gap: 0.7rem; flex-wrap: wrap; }
.mini-field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.78rem; color: var(--text-muted); font-weight: 600; flex: 1; min-width: 140px; }
.mini-field input, .mini-field select {
  border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem; background: var(--bg); font-size: 0.88rem;
}
.task-form .btn { align-self: flex-end; }

/* ---------- view tabs ---------- */
.view-tabs { display: flex; gap: 1.3rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.view-tab {
  background: none; border: none; padding: 0.6rem 0.1rem; font-weight: 600; font-size: 0.92rem;
  color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.view-tab.is-active { color: var(--text); border-bottom-color: var(--accent); }
.view-tab-hint { font-weight: 400; font-size: 0.78rem; opacity: 0.7; }

/* ---------- task list: the "index card" signature ---------- */
.task-list { display: flex; flex-direction: column; gap: 0.7rem; }

.task-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem 0.9rem 0.9rem;
  overflow: hidden;
  box-shadow: var(--shadow);
}

/* priority punch-tab on the left edge */
.task-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 6px;
  background: var(--tab-color, var(--border));
}
.task-card[data-priority="high"] { --tab-color: var(--danger); }
.task-card[data-priority="medium"] { --tab-color: var(--amber); }
.task-card[data-priority="low"] { --tab-color: var(--mint); }

.task-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 0.15rem;
  display: flex; align-items: center; justify-content: center;
}
.task-card.is-done .task-check { background: var(--mint); border-color: var(--mint); }
.task-check svg { opacity: 0; }
.task-card.is-done .task-check svg { opacity: 1; }

.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 0.98rem; word-break: break-word; }
.task-card.is-done .task-title { text-decoration: line-through; color: var(--text-muted); }
.task-desc { font-size: 0.86rem; color: var(--text-muted); margin-top: 0.2rem; word-break: break-word; }
.task-meta { display: flex; gap: 0.7rem; flex-wrap: wrap; margin-top: 0.45rem; font-size: 0.74rem; color: var(--text-muted); }
.task-meta span { display: inline-flex; align-items: center; gap: 0.3rem; }

.task-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }
.task-actions button {
  border: none; background: none; color: var(--text-muted); cursor: pointer;
  width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.task-actions button:hover { background: var(--surface-2); color: var(--danger); }

/* the rubber-stamp mark for completed / archived tasks */
.task-card.is-done .stamp {
  position: absolute;
  right: 0.8rem;
  top: 0.6rem;
  border: 2px solid var(--mint);
  color: var(--mint);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  transform: rotate(-8deg);
  opacity: 0.85;
  pointer-events: none;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
  font-size: 0.95rem;
}

/* ---------- devices modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(10, 16, 14, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem;
}
.modal-card {
  width: 100%; max-width: 420px; background: var(--surface); border-radius: 14px;
  border: 1px solid var(--border); padding: 1.2rem; box-shadow: var(--shadow);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.8rem; }
.devices-list { display: flex; flex-direction: column; gap: 0.6rem; max-height: 50vh; overflow-y: auto; }
.device-row {
  display: flex; justify-content: space-between; align-items: center;
  border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem 0.7rem; font-size: 0.85rem;
}
.device-row .device-label { font-weight: 600; }
.device-row .device-time { color: var(--text-muted); font-size: 0.75rem; }
.device-row .badge-current { font-size: 0.7rem; color: var(--mint); font-weight: 700; }

@media (max-width: 480px) {
  .app-main { padding: 1rem 0.8rem 3rem; }
  .composer-row { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
