/* timealloc — minimal PWA shell */

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

:root {
  --bg: rgb(230, 86, 122);
  --ink: #1a1a1a;
  --ink-soft: rgba(26, 26, 26, 0.72);
  --surface: rgba(255, 255, 255, 0.22);
  --surface-strong: rgba(255, 255, 255, 0.38);
  --surface-hover: rgba(255, 255, 255, 0.5);
  --line: rgba(26, 26, 26, 0.12);
  --radius: 14px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
}

/* ——— views ——— */
.view {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  padding: 16px 16px 0;
  padding-top: max(16px, env(safe-area-inset-top, 0px));
}

.view.is-active {
  display: flex;
}

/* Log: upper third picker, lower two thirds feed */
.log-top {
  flex: 0 0 33%;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 12px;
}

.log-bottom {
  flex: 1 1 67%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.summary-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
}

/* ——— search + dropdown ——— */
.picker-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.search-wrap {
  flex: 1;
  position: relative;
}

.search-input {
  width: 100%;
  height: 48px;
  border: none;
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* avoids iOS zoom on focus */
  padding: 0 14px;
  outline: none;
  box-shadow: inset 0 0 0 1px var(--line);
}

.search-input::placeholder {
  color: var(--ink-soft);
}

.search-input:focus {
  box-shadow: inset 0 0 0 2px rgba(26, 26, 26, 0.35);
}

/* custom control (not native button chrome) */
.icon-control {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
  appearance: none;
  font: inherit;
  padding: 0;
}

.icon-control:active {
  background: var(--surface-hover);
}

.icon-control:disabled {
  opacity: 0.35;
  cursor: default;
}

.icon-control svg {
  width: 22px;
  height: 22px;
  display: block;
}

.category-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.category-list:empty::after {
  content: "No categories yet — type a name and tap +";
  display: block;
  padding: 14px;
  color: var(--ink-soft);
  font-size: 14px;
}

.category-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  padding: 14px 16px;
  cursor: pointer;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  border-bottom: 1px solid var(--line);
}

.category-item:last-child {
  border-bottom: none;
}

.category-item:active {
  background: var(--surface-hover);
}

.category-item.is-selected {
  background: var(--surface-hover);
  font-weight: 600;
  box-shadow: inset 3px 0 0 rgba(26, 26, 26, 0.55);
}

.batch {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
  align-items: center;
}

.batch-hint {
  font-size: 13px;
  color: var(--ink-soft);
}

.batch-chip {
  border: none;
  appearance: none;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface-strong);
  box-shadow: inset 0 0 0 1px var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-chip:active {
  background: var(--surface-hover);
}

.icon-control-commit:not(:disabled) {
  background: rgba(26, 26, 26, 0.88);
  color: #fff;
  box-shadow: none;
}

.icon-control-commit:not(:disabled):active {
  background: rgba(26, 26, 26, 0.75);
}

/* ——— feed + summary lists ——— */
.section-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.feed,
.totals {
  list-style: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.feed-item,
.total-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.feed-item .cat,
.total-item .cat {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-item .when,
.total-item .amt {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  font-size: 13px;
}

.feed:empty::after,
.totals:empty::after {
  content: "Nothing logged yet";
  display: block;
  padding: 12px 4px;
  color: var(--ink-soft);
  font-size: 14px;
}

/* ——— bottom nav ——— */
.bottom-nav {
  flex: 0 0 auto;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  border-top: 1px solid var(--line);
  background: rgba(230, 86, 122, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.nav-item {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  opacity: 0.45;
  padding: 0;
  font: inherit;
}

.nav-item.is-active {
  opacity: 1;
}

.nav-item:active {
  opacity: 0.8;
}

.nav-item svg {
  width: 28px;
  height: 28px;
  display: block;
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  transform: translateX(-50%) translateY(12px);
  background: rgba(26, 26, 26, 0.88);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
  max-width: calc(100% - 32px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
