:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --base: #111222;
  --surface: #1a1c30;
  --input: #131526;
  --border: #34364f;
  --ink: #f5f3ff;
  --muted: #b1b1ca;
  --accent: #c8bcff;
  --accent-ink: #231849;
  --danger: #ffc2cb;
  background: var(--base);
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(ellipse at 50% -20%, #2a2351, transparent 32rem), var(--base);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .65; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid #ddd4ff;
  outline-offset: 2px;
}
.shell {
  width: min(100%, 44rem);
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 1.15rem) 1.15rem max(env(safe-area-inset-bottom), 1.4rem);
}
.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .25rem 0 1rem;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .65rem; font-size: 1.06rem; font-weight: 700; }
.brand img { border-radius: .75rem; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.8rem, 5.7vw, 2.5rem); line-height: 1.1; letter-spacing: -.045em; }
h2 { font-size: 1.25rem; letter-spacing: -.025em; }
.muted { color: var(--muted); line-height: 1.55; }
#boot { padding: 3rem 0; color: var(--muted); }
.gate {
  max-width: 26rem;
  margin: clamp(2rem, 7vw, 5rem) auto 0;
  padding: clamp(1.25rem, 5vw, 2rem);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  background: var(--surface);
  box-shadow: 0 1.5rem 5rem #08091455;
}
.gate h1 { margin-top: 1rem; }
.gate > p { margin-top: .7rem; }
.gate form { margin-top: 1.4rem; }
label { display: block; font-size: .9rem; font-weight: 650; margin-bottom: .42rem; }
input:not([type=file]), textarea {
  display: block;
  width: 100%;
  min-height: 46px;
  color: var(--ink);
  padding: .7rem .8rem;
  border: 1px solid var(--border);
  border-radius: .65rem;
  background: var(--input);
}
textarea { resize: vertical; line-height: 1.5; }
#confirmation-field, #gate-submit { margin-top: .85rem; }
#gate-submit { width: 100%; }
.primary, .quiet, .danger {
  min-height: 44px;
  padding: .55rem .85rem;
  border: 1px solid transparent;
  border-radius: .7rem;
  font-size: .875rem;
  font-weight: 700;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.quiet { border-color: var(--border); color: var(--ink); background: var(--surface); }
.danger { border-color: #7c4357; background: #482738; color: var(--danger); }
.privacy-emblem, .empty-icon {
  display: grid;
  place-items: center;
  width: 3.1rem;
  height: 3.1rem;
  color: var(--accent);
  background: #30274d;
  border: 1px solid #554875;
  border-radius: .9rem;
}
.lock-icon {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 13px;
  margin-top: 6px;
  border: 2px solid currentColor;
  border-radius: 4px;
}
.lock-icon::before {
  content: "";
  position: absolute;
  width: 7px;
  height: 8px;
  left: 50%;
  top: -8px;
  transform: translateX(-50%);
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
}
.lock-icon.small { transform: scale(.8); }
.library-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin: 1.85rem 0 1.3rem;
}
.library-heading p { margin-top: .35rem; font-size: .88rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.search { position: relative; flex: 1 1 11rem; margin: 0; }
.search input { padding-left: 2.3rem; font-weight: 400; font-size: 1rem; }
.search-icon {
  position: absolute;
  top: 15px;
  left: 14px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  pointer-events: none;
}
.search-icon::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 2px;
  transform: rotate(45deg);
  left: 9px;
  top: 10px;
  background: var(--muted);
}
.filters { display: flex; flex-wrap: wrap; gap: .25rem; margin: .65rem 0 1rem; }
.filters button {
  min-height: 44px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: .9rem;
  padding: 0 .8rem;
  border-radius: .65rem;
}
.filters button[aria-pressed=true] { background: #30274d; border-color: #514370; color: #e9e0ff; }
.items { display: grid; gap: .6rem; }
.item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .35rem;
  border: 1px solid var(--border);
  border-radius: .9rem;
  background: var(--surface);
  padding: .35rem;
}
.item-preview {
  width: 100%;
  min-width: 0;
  padding: .6rem .55rem;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: .6rem;
}
.item-kind { color: var(--accent); font-size: .8rem; font-weight: 700; }
.item-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: .25rem; }
.item-actions { display: flex; gap: .3rem; }
.item-actions button { padding: .35rem .55rem; }
.item-actions [aria-pressed=true] { color: var(--accent); border-color: #6a578e; }
.empty {
  text-align: center;
  padding: 2.6rem 1.2rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 1rem;
}
.empty-icon { margin: 0 auto .8rem; font-size: 1.6rem; }
.empty p { margin-top: .4rem; }
footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .4rem;
  margin: 1.15rem auto 0;
  color: var(--muted);
  font-size: .875rem;
}
.text-button {
  background: transparent;
  color: var(--accent);
  border: 0;
  border-radius: .4rem;
  min-height: 44px;
  padding: 0 .65rem;
}
.error { margin-top: .65rem; color: var(--danger); line-height: 1.45; }
.notice {
  position: fixed;
  z-index: 1;
  bottom: max(env(safe-area-inset-bottom), 1rem);
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 2rem);
  width: max-content;
  padding: .75rem 1rem;
  border: 1px solid #5e517c;
  border-radius: .75rem;
  color: var(--ink);
  background: #28213c;
  box-shadow: 0 .65rem 2rem #09091677;
}
dialog {
  width: min(calc(100% - 2rem), 28rem);
  max-height: calc(100dvh - 2rem);
  padding: 1.25rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #554c71;
  border-radius: 1rem;
}
dialog::backdrop { background: #080914bb; }
dialog h2 { margin-bottom: .75rem; }
dialog p, dialog input[type=file] { margin-bottom: .85rem; }
dialog input[type=file] { width: 100%; font-size: .875rem; }
dialog input[type=file]::file-selector-button {
  min-height: 44px;
  margin-right: .65rem;
  background: #30274d;
  color: var(--ink);
  border: 1px solid #554875;
  border-radius: .6rem;
}
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .45rem; margin-top: 1rem; }
dt { font-weight: 700; margin: .9rem 0 .25rem; }
dd { color: var(--muted); margin-left: 0; line-height: 1.5; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.obscured { visibility: hidden; }
