/* Dark, mobile-first, no framework. The screen this runs on is a phone in
   a shop, so: large tap targets, high contrast, no animation. */

:root {
  --bg: #1a1a1a;
  --panel: #242424;
  --line: #333;
  --text: #f0f0f0;
  --muted: #999;
  --accent: #7aa2f7;
  --warn: #e0af68;
  --error: #f7768e;
}

* {
  box-sizing: border-box;
}

/* The `hidden` attribute is how this application shows and hides screens,
   and every `display` rule below would quietly outrank it. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

h1 {
  font-size: 22px;
  margin: 24px 16px 16px;
}

.screen,
main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 12px 40px;
}

input,
button,
textarea,
select {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}

button {
  cursor: pointer;
}

button:active {
  opacity: 0.6;
}

/* --- banner --------------------------------------------------------------- */

.banner {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 10px 16px;
  background: var(--accent);
  color: #12141c;
  font-size: 15px;
  white-space: pre-wrap;
}

.banner.error {
  background: var(--error);
}

.banner.offline {
  background: var(--warn);
}

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

#login-form,
#add-form,
#search-form {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

#login-form input,
#add-form input,
#search-form input {
  flex: 1;
  min-width: 0;
}

#add-form button {
  width: 52px;
  font-size: 22px;
  line-height: 1;
}

.error {
  color: var(--error);
  margin: 8px 0;
}

/* --- tabs ----------------------------------------------------------------- */

#tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}

#tabs::-webkit-scrollbar {
  display: none;
}

#tabs button {
  flex: 0 0 auto;
  padding: 8px 12px;
  font-size: 15px;
  background: none;
  border-color: transparent;
  color: var(--muted);
}

#tabs button.active {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
}

/* --- lists ---------------------------------------------------------------- */

h2 {
  font-size: 14px;
  font-weight: 600;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 20px 4px 8px;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

li:last-child {
  border-bottom: none;
}

.body {
  flex: 1;
  min-width: 0;
}

.item .title {
  display: block;
  overflow-wrap: anywhere;
}

.meta {
  display: block;
  font-size: 13px;
  color: var(--muted);
}

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

.item.review .title::after {
  content: " ?";
  color: var(--warn);
}

.tick {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 7px;
}

.item.done .tick {
  background: var(--accent);
  border-color: var(--accent);
}

.edit {
  background: none;
  border: none;
  color: var(--muted);
  padding: 6px 4px;
}

.empty {
  color: var(--muted);
  padding: 24px 4px;
}

.pending {
  opacity: 0.55;
}

/* --- editor --------------------------------------------------------------- */

.editor-row {
  display: block;
  padding: 0;
}

.editor {
  display: grid;
  /* minmax(0, 1fr) rather than a bare column: a grid track refuses to go
     below its content's min-content width, and an <input> insists on about
     twenty characters. Without this the editor is wider than the list it
     sits in and the "Убрать" button is clipped away. */
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.editor-row .editor {
  border-radius: 0;
  border-width: 0 0 1px;
}

.editor .row {
  display: flex;
  gap: 8px;
}

.editor .row input {
  flex: 1;
  min-width: 0;
}

.editor .actions {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

textarea {
  width: 100%;
  min-height: 320px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.version {
  justify-content: space-between;
}

.version.active {
  border-left: 3px solid var(--accent);
}

.raw {
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
