:root {
  --ink: #1c1712;
  --paper: #f3ead8;
  --card: #fff8ec;
  --rust: #c45c26;
  --line: #d9cbb3;
  --muted: #7a6d5d;
  --ok: #2f6f4e;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", "IBM Plex Sans", system-ui, sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, #3a2a1c 0%, transparent 55%),
    var(--ink);
  color: var(--ink);
}

.hidden { display: none !important; }

.stamp {
  margin: 0 0 0.35rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.7rem;
  color: var(--rust);
  font-weight: 700;
}

h1 { margin: 0; font-size: 1.7rem; letter-spacing: -0.03em; }
.app-version {
  margin-left: 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--muted);
  vertical-align: 0.15em;
}
.lede { color: var(--muted); margin: 0.4rem 0 1.2rem; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.gate-card, .layout, .preview {
  background: var(--paper);
  border: 1px solid #00000022;
  box-shadow: 0 18px 50px #00000066;
}
.gate-card {
  width: min(420px, 100%);
  padding: 1.6rem;
  border-radius: 18px;
}

label { display: block; margin: 0.8rem 0; font-size: 0.9rem; font-weight: 600; }
input, textarea, button {
  font: inherit;
  color: inherit;
}
input, textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
button {
  border: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.75rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
}
button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.file-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px dashed var(--rust);
  color: var(--rust);
  cursor: pointer;
  margin: 0;
}
.error { color: #9b1c1c; font-size: 0.9rem; }

.layout {
  width: min(920px, calc(100% - 1.5rem));
  margin: 1.2rem auto 3rem;
  padding: 1.2rem;
  border-radius: 22px;
}
.top, .composer-bar, .item-actions, .preview-head {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.top { margin-bottom: 1rem; }
.top-actions { display: flex; gap: 0.5rem; flex: 1; justify-content: flex-end; }
.search-box {
  display: flex;
  gap: 0.35rem;
  flex: 1;
  max-width: 360px;
  margin: 0;
}
.search-box input {
  margin: 0;
  flex: 1;
  min-width: 0;
}
.search-box button {
  padding: 0.55rem 0.9rem;
}
.search-box input[type="search"]::-webkit-search-cancel-button {
  appearance: none;
}
.search-clear {
  min-width: 2.2rem;
  padding: 0.45rem 0.65rem;
  font-size: 1.15rem;
  line-height: 1;
}
mark {
  background: #ffe566;
  color: inherit;
  padding: 0 0.12em;
  border-radius: 2px;
}

.composer {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.8rem;
}
.composer-bar { margin-top: 0.6rem; }
.paste-preview-wrap {
  display: flex;
  align-items: flex-end;
  gap: 0.7rem;
  margin-top: 0.65rem;
  flex-wrap: wrap;
}
.paste-preview-wrap img {
  max-width: min(100%, 320px);
  max-height: 180px;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: block;
}
.muted { color: var(--muted); font-size: 0.85rem; }

.list { margin-top: 1rem; display: grid; gap: 0.75rem; }
.item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
}
.item.pinned { border-color: var(--rust); }
.meta {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 0.45rem;
}
.body {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 0.7rem;
  line-height: 1.4;
}
.edit-body {
  display: block;
  width: 100%;
  min-height: 6rem;
  margin: 0 0 0.7rem;
  resize: vertical;
  line-height: 1.4;
}
.thumb {
  max-width: 100%;
  max-height: 220px;
  border-radius: 10px;
  margin-bottom: 0.7rem;
  display: block;
}
.item-actions button { padding: 0.45rem 0.8rem; font-size: 0.85rem; }

.check-list { margin: 0.2rem 0 0.25rem; }
.list-hint {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.15rem 0;
}
.check-row input[type="checkbox"] {
  -webkit-appearance: checkbox;
  appearance: auto;
  width: 1.15rem !important;
  min-width: 1.15rem;
  height: 1.15rem !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: #fff;
  flex: 0 0 1.15rem;
  cursor: pointer;
  accent-color: var(--ink);
}
.composer-checks {
  margin: 0.35rem 0 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.check-text {
  flex: 1;
  margin: 0;
  padding: 0.25rem 0.2rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  width: auto;
}
.check-view {
  min-height: 1.4em;
  word-break: break-word;
  cursor: text;
}
.check-row.is-done .check-text {
  color: var(--muted);
  text-decoration: line-through;
}
.check-row.is-done .check-view a {
  text-decoration: underline line-through;
}
.check-done-head {
  margin: 0.55rem 0 0.2rem;
  padding: 0.35rem 0;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  width: 100%;
  justify-content: flex-start;
  font-size: 0.85rem;
  font-weight: 700;
}

.tabs { display: flex; gap: 0.4rem; margin: 0 0 0.7rem; }
.tab {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
}
.tab.is-on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.filters { margin: 0 0 0.8rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.65rem 0 0;
}
.pill {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}
.pill.is-on {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.clip-tags { margin: 0.35rem 0 0.65rem; }
.tag-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
}
.tag-row strong { font-size: 0.95rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--rust);
  color: var(--rust);
  background: #c45c2614;
  border-radius: 999px;
  padding: 0.25rem 0.55rem 0.25rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 700;
}
.chip button {
  background: transparent;
  color: var(--rust);
  padding: 0 0.2rem;
  font-size: 1rem;
  line-height: 1;
}
.tag {
  display: inline;
  border: 0;
  background: transparent;
  color: var(--rust);
  padding: 0;
  font-size: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.item.archived { opacity: 0.85; }

.section-title { margin: 0 0 0.6rem; font-size: 1.05rem; }
.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}
.check input { width: auto; margin: 0; }
.btn-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  font-weight: 700;
}
.table-wrap { overflow-x: auto; }
table.users {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
table.users th, table.users td {
  text-align: left;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  vertical-align: middle;
}
table.users th { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
table.users tr:last-child td { border-bottom: 0; }
table.users .item-actions { flex-wrap: wrap; justify-content: flex-start; }
a { color: var(--rust); }

.preview {
  width: min(720px, 94vw);
  border: 0;
  border-radius: 16px;
  padding: 1rem;
}
.preview::backdrop { background: #0008; }
.preview pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--ink);
  color: var(--paper);
  padding: 1rem;
  border-radius: 10px;
  overflow: auto;
  max-height: 60vh;
}

@media (max-width: 640px) {
  .search-box { max-width: none; width: 100%; }
  .top-actions { width: 100%; }
}
