/* Base: reset, typography, form controls, buttons and small shared widgets. */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color .45s ease, color .45s ease;
}
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--faint); font-size: 13px; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }

/* Scrollbars */
:root { scrollbar-color: var(--panel-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border); background-clip: padding-box; }

/* ---- Form controls: one look, one height ---- */
.composer input, .composer textarea, .composer select,
.field input, .field textarea, .field select,
.toolbar select, .topbar input[type="search"],
.add-proj input, .att-edit input, .tag-edit input {
  width: 100%;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .2s;
}
.composer input:not([type="checkbox"]), .composer select,
.field input:not([type="checkbox"]), .field select,
.toolbar select, .topbar input[type="search"],
.add-proj input, .att-edit input, .tag-edit input {
  height: var(--h-md);
  padding: 0 12px;
}
.composer textarea, .field textarea {
  padding: 9px 12px;
  min-height: 64px;
  line-height: 1.5;
  resize: vertical;
}
.composer input:hover:not(:focus), .composer textarea:hover:not(:focus), .composer select:hover:not(:focus),
.field input:hover:not(:focus), .field textarea:hover:not(:focus), .field select:hover:not(:focus),
.toolbar select:hover:not(:focus), .topbar input[type="search"]:hover:not(:focus) {
  border-color: var(--border-2);
}
.composer input:focus, .composer textarea:focus, .composer select:focus,
.field input:focus, .field textarea:focus, .field select:focus,
.toolbar select:focus, .topbar input[type="search"]:focus,
.add-proj input:focus, .att-edit input:focus, .tag-edit input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
  background: var(--panel);
}
input::placeholder, textarea::placeholder { color: var(--faint); }

/* Custom chevron instead of the native select arrow */
.composer select, .field select, .toolbar select {
  appearance: none;
  -webkit-appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 12px 12px;
  padding-right: 32px;
  cursor: pointer;
}
.toolbar select, .topbar input[type="search"] { background-color: var(--panel); border-radius: var(--r-md); }
.toolbar select { width: auto; }

input[type="date"] { font-variant-numeric: tabular-nums; padding-right: 10px; }
input[type="date"]::-webkit-calendar-picker-indicator { opacity: .5; cursor: pointer; border-radius: 4px; transition: opacity .15s, background .15s; }
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; background: var(--panel-3); }

/* ---- Buttons ---- */
button { font-family: inherit; cursor: pointer; }
button.btn, button.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--h-md);
  padding: 0 14px;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  border-radius: var(--r-sm);
}
button.btn {
  border: 1px solid transparent;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 3px 10px rgba(79, 110, 247, .3);
  transition: transform .16s var(--ease), filter .2s, box-shadow .2s;
}
button.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
button.btn:active { transform: translateY(0) scale(.97); }
button.btn.danger { background: var(--high); box-shadow: none; }
button.ghost {
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 500;
  box-shadow: var(--inset-top);
  transition: background .18s, color .18s, transform .16s, border-color .18s;
}
button.ghost:hover { background: var(--panel-3); color: var(--text); border-color: var(--border-2); transform: translateY(-1px); }
button.ghost:active { transform: translateY(0) scale(.96); }
button.ghost.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
button.ghost.danger:hover { color: var(--high); border-color: var(--high); }

/* Compact tier (28px): secondary / inline actions */
.composer-foot button.ghost, .field-head button.ghost, .bulkbar button.ghost,
.actions button.ghost, .now-spot button.ghost, .triage-keys button, .triage-hits button {
  height: var(--h-sm);
  padding: 0 11px;
  font-size: 12px;
  border-radius: var(--r-xs);
}
.desc-more { height: var(--h-xs); padding: 0 9px; margin-top: 6px; font-size: 12px; border-radius: var(--r-xs); }
.subedit button, .att-edit button, .tag-edit button { height: 34px; min-width: 34px; padding: 0 11px; font-size: 13px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: var(--h-md);
  height: var(--h-md);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  box-shadow: var(--inset-top);
  transition: transform .18s var(--ease), background .2s, color .2s, border-color .2s, box-shadow .2s;
}
.icon-btn:hover { color: var(--text); background: var(--panel-3); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.icon-btn:active { transform: translateY(0) scale(.94); }
.icon-btn svg { width: 17px; height: 17px; }

.kbd {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  color: var(--text);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
