/*
 * Brownies — styles. No build step, plain CSS custom properties.
 * Phone: bottom nav, single column. Laptop (>=760px): sidebar, grids.
 */

:root {
  --bg: #1b1410;
  --surface: #251a13;
  --surface-2: #2f2118;
  --text: #f5ece4;
  --muted: #c9b8aa;
  --accent: #e08a4c;
  --accent-strong: #f0a05e;
  --on-accent: #241408;
  --border: #3a2b21;
  --focus: #8fd0ff;
  --danger: #e56b5d;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --tap: 44px;
}

[data-theme='light'] {
  --bg: #fbf6f1;
  --surface: #ffffff;
  --surface-2: #f3e9df;
  --text: #2b1d15;
  --muted: #6b564a;
  --accent: #965016;
  --accent-strong: #7a3f0f;
  --on-accent: #fff7ef;
  --border: #e6d8cc;
  --focus: #1f6feb;
  --danger: #c0392b;
  --shadow: 0 10px 26px rgba(70, 45, 25, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

.noscript {
  padding: 1rem;
  text-align: center;
}

/* ------------------------------------------------------------ a11y aids */

.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;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  z-index: 60;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 0 0 10px 10px;
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

/* --------------------------------------------------------------- layout */

.app {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  z-index: 40;
}

.sidebar.open {
  transform: translateX(0);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.15rem;
}

.brand-mark {
  font-size: 1.4rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  min-height: var(--tap);
  padding: 0.6rem 0.8rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.nav-btn:hover {
  background: var(--surface-2);
}

.nav-btn[aria-current='page'] {
  background: var(--surface-2);
  border-color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  font-size: 1.1rem;
}

.badge {
  margin-left: auto;
  min-width: 1.5rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sync-note {
  font-size: 0.78rem;
  color: var(--muted);
}

.main {
  min-height: 100vh;
  padding-bottom: 5.5rem;
}

.topbar {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 20;
}

.view-title {
  font-size: 1.4rem;
  line-height: 1.2;
}

.view-date {
  color: var(--muted);
  font-size: 0.9rem;
}

.view {
  padding: 1rem;
  max-width: 900px;
  margin: 0 auto;
}

/* --------------------------------------------------------------- forms */

.composer {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.composer.stacked {
  flex-direction: column;
  align-items: stretch;
}

input,
select,
textarea {
  min-height: var(--tap);
  padding: 0.55rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  width: 100%;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

.search {
  margin-top: 0.75rem;
}

.btn {
  min-height: var(--tap);
  padding: 0.55rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--accent);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  min-height: var(--tap);
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
}

.icon-btn {
  min-width: var(--tap);
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.05rem;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

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

.menu-btn {
  display: inline-flex;
}

/* --------------------------------------------------------------- tasks */

.section-hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0.6rem 0;
}

.history-note {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0.4rem 0 0.9rem;
}

.subsection-title {
  font-size: 1rem;
  margin: 1.2rem 0 0.5rem;
  color: var(--muted);
}

.task-list,
.inbox-list,
.note-list,
.habit-list,
.focus-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.task {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.task.done .task-title {
  text-decoration: line-through;
  color: var(--muted);
}

.check {
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  border-radius: 10px;
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--on-accent);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.check[aria-checked='true'] {
  background: var(--accent);
}

.task-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.task-date {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.done-list .task {
  opacity: 0.75;
}

/* --------------------------------------------------------------- inbox */

.inbox-item {
  padding: 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.inbox-text {
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------- notes */

.note {
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.note-title {
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
  overflow-wrap: anywhere;
}

.note-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
}

.note-meta {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.note-editor {
  padding: 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.row-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

/* -------------------------------------------------------------- habits */

.habit {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.habit-info {
  flex: 1 1 auto;
  min-width: 0;
}

.habit-name {
  font-size: 1.02rem;
  overflow-wrap: anywhere;
}

.habit-streak {
  color: var(--accent-strong);
  font-weight: 600;
  font-size: 0.9rem;
}

.habit-week {
  font-size: 0.8rem;
  color: var(--muted);
}

.week-dots {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.45rem;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.dot.on {
  background: var(--accent);
  border-color: var(--accent);
}

/* --------------------------------------------------------------- focus */

.focus-card {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow);
}

.focus-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
}

.focus-timer {
  font-size: clamp(3rem, 16vw, 5.5rem);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1.1;
  margin: 0.4rem 0;
}

.focus-task {
  color: var(--muted);
  margin-bottom: 0.9rem;
  overflow-wrap: anywhere;
}

.focus-form {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.focus-form select {
  width: auto;
  max-width: 12rem;
}

.focus-form input[type='number'] {
  width: 5.5rem;
}

.focus-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.focus-item-meta {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ------------------------------------------------------------- feedback */

.empty {
  padding: 1.25rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-top: 1rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 5.5rem;
  transform: translateX(-50%);
  padding: 0.6rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 70;
  max-width: 90vw;
}

.dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 1.25rem;
  max-width: 24rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ----------------------------------------------------------- bottom nav */

.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 30;
}

.bottomnav-btn {
  flex: 1 1 0;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.72rem;
}

.bottomnav-btn .nav-icon {
  font-size: 1.15rem;
}

.bottomnav-btn[aria-current='page'] {
  color: var(--accent-strong);
  font-weight: 600;
}

/* ------------------------------------------------------------ responsive */

@media (min-width: 760px) {
  .sidebar {
    position: sticky;
    inset: auto;
    top: 0;
    height: 100vh;
    transform: none;
    flex: 0 0 260px;
  }

  .menu-btn {
    display: none;
  }

  .app {
    display: flex;
    align-items: flex-start;
  }

  .main {
    flex: 1 1 auto;
    padding-bottom: 2rem;
  }

  .view {
    padding: 1.5rem 2rem;
    max-width: 1100px;
  }

  .bottomnav {
    display: none;
  }

  .note-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    align-items: start;
  }

  .note-list .note-editor {
    grid-column: 1 / -1;
  }

  .habit-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    align-items: start;
  }

  .focus-card {
    max-width: 34rem;
    margin: 0 auto;
  }

  .toast {
    bottom: 1.5rem;
  }
}

/* ------------------------------------------------------ reduced motion */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
