/* JetBrains Mono, self-hosted (like htmx) so binbash stays a single
   self-contained, offline-capable binary with no external font requests on
   page load. These are the variable-weight woff2 files from Google Fonts; the
   latin + latin-ext subsets cover Western text including accented characters,
   and any glyph outside those ranges falls back to the system monospace font
   in --font-mono. font-weight is a 400-700 range because one variable file
   serves both the regular and bold weights. */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/static/fonts/jetbrains-mono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/static/fonts/jetbrains-mono-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --color-bg: #2e3440;
  --color-surface: #3b4252;
  --color-text: #eceff4;
  --color-subtle: #d8dee9;
  --color-accent: #88c0d0;
  --color-accent-dark: #81a1c1;
  --color-border: #4c566a;
  --color-error: #e58c94;
  --radius: 12px;
  --spacing: 1rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-mono);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

/* Form controls don't inherit the page font by default, so opt them all in
   explicitly — otherwise buttons and the bin dropdown would fall back to the
   browser's sans-serif and break the consistent monospace look. */
button,
input,
select,
textarea {
  font-family: inherit;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-accent-dark);
  text-decoration: none;
}

.top-nav {
  display: none;
}

.top-nav a,
.tab-bar a {
  text-decoration: none;
  font-weight: 600;
}

.top-nav a {
  color: var(--color-subtle);
}

.top-nav a:hover,
.top-nav a.active {
  color: var(--color-accent-dark);
}

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

.tab-bar a {
  flex: 1;
  text-align: center;
  padding: 0.6rem 0.25rem;
  font-size: 0.75rem;
  color: var(--color-subtle);
}

.tab-bar a.active {
  color: var(--color-accent);
}

main {
  padding: var(--spacing);
  padding-bottom: calc(var(--spacing) + 4.5rem);
  max-width: 32rem;
  margin: 0 auto;
}

@media (min-width: 640px) {
  .top-nav {
    display: flex;
    gap: 1rem;
  }

  .tab-bar {
    display: none;
  }

  main {
    padding-bottom: var(--spacing);
  }
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 1.5rem;
}

h1 {
  margin-top: 0;
  font-size: 1.5rem;
}

h2 {
  font-size: 1.15rem;
}

.subtle {
  color: var(--color-subtle);
}

.error {
  color: var(--color-error);
  font-weight: 600;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

input,
textarea {
  width: 100%;
  padding: 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 1rem;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

button {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 8px;
  background: var(--color-accent);
  color: var(--color-bg);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: var(--color-accent-dark);
}

button.secondary {
  background: transparent;
  color: var(--color-subtle);
  border: 1px solid var(--color-border);
}

button.secondary:hover {
  background: var(--color-bg);
}

button.danger {
  background: var(--color-error);
  color: var(--color-bg);
}

button.danger:hover {
  filter: brightness(0.92);
}

.button-link {
  display: block;
  text-align: center;
  padding: 0.75rem;
  border-radius: 8px;
  background: var(--color-accent);
  color: var(--color-bg);
  font-weight: 600;
  text-decoration: none;
  margin-bottom: 1rem;
}

.button-link:hover {
  background: var(--color-accent-dark);
}

.bin-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.bin-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}

.bin-row:last-child {
  border-bottom: none;
}

.bin-row p {
  margin: 0.25rem 0 0;
}

.bin-row a {
  color: var(--color-accent-dark);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.bin-row a:hover {
  text-decoration: underline;
}

.row-actions {
  display: flex;
  gap: 0.75rem;
  white-space: nowrap;
}

.row-actions a.delete {
  color: var(--color-error);
}

.badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  color: var(--color-subtle);
  font-size: 0.75rem;
  font-weight: 600;
}

.item-keywords {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
}

/* Expandable bin contents on the bins page. <details> gives us open/close for
   free, with no JavaScript and no round trip — the items are already in the
   page. The bin's Edit/Delete links stay outside the <details> (they'd be
   nested interactive elements inside <summary>, where a click would toggle the
   panel instead of following the link), so the row keeps its existing layout
   and the disclosure only adds the contents underneath. */
.bin-details {
  flex: 1;
  min-width: 0;
}

.bin-details summary {
  cursor: pointer;
  list-style: none;
}

/* Suppress the platform disclosure marker in favour of the .bin-title arrow
   below, which we can colour and align with the rest of the row. */
.bin-details summary::-webkit-details-marker {
  display: none;
}

.bin-title::before {
  content: "▸";
  display: inline-block;
  width: 1.1rem;
  color: var(--color-accent-dark);
}

.bin-details[open] .bin-title::before {
  content: "▾";
}

.bin-details summary:hover strong {
  color: var(--color-accent);
}

.bin-details summary:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* Line the description up under the bin name rather than under the arrow. */
.bin-description {
  margin-left: 1.1rem;
}

.bin-contents {
  margin: 0.5rem 0 0.25rem 1.1rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--color-border);
}

.item-sublist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item-sublist li {
  padding: 0.3rem 0;
  font-size: 0.9rem;
}

.item-sublist a {
  color: var(--color-text);
  /* .bin-row a sets nowrap for the Edit/Delete links; item names are free text
     and need to wrap. */
  white-space: normal;
}

.item-sublist a:hover {
  color: var(--color-accent);
}

.add-to-bin {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

/* Update panel on the settings page. */
.update-panel {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
}

.update-panel p {
  margin-top: 0;
}

.update-panel form {
  margin-bottom: 0.75rem;
}

.update-panel a {
  color: var(--color-accent-dark);
}

.update-hint {
  font-size: 0.85rem;
  margin-bottom: 0;
}

.update-success {
  color: var(--color-accent);
  font-weight: 600;
}

.back-link {
  display: inline-block;
  margin-top: 0.5rem;
  color: var(--color-subtle);
  text-decoration: none;
}

.back-link:hover {
  color: var(--color-accent-dark);
}

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.checkbox-field input[type="checkbox"] {
  width: auto;
  margin: 0.25rem 0 0;
}

.checkbox-field label {
  margin-bottom: 0;
  font-weight: 400;
}

.stats {
  display: flex;
  gap: 2rem;
  margin: 1.5rem 0;
}

.stats dt {
  font-size: 0.85rem;
  color: var(--color-subtle);
}

.stats dd {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-accent-dark);
}
