:root {
  --bg: #000;
  --panel: #111;
  --panel-2: #181818;
  --line: rgba(255,255,255,.10);
  --text: #f4f4f4;
  --muted: #8e8e93;
  --accent: #d8d8d8;
  --danger: #ff453a;
  --ok: #30d158;
  --tab-h: 74px;
  --top-h: 82px;
  --font-note: 22px;
  --radius: 20px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }

.app-shell {
  height: 100dvh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% -10%, rgba(60,60,60,.22), transparent 42%), #000;
  padding-top: env(safe-area-inset-top);
}

.topbar {
  height: var(--top-h);
  flex: 0 0 var(--top-h);
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 8px;
  border-bottom: 1px solid rgba(255,255,255,.05);
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(18px);
}
.round-btn {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.08);
  display: grid;
  place-items: center;
  font-size: 25px;
  line-height: 1;
  padding: 0;
}
.round-btn:active { transform: scale(.96); background: rgba(255,255,255,.14); }
.title-block { min-width: 0; text-align: center; }
.tab-title {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.screen {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.note-list, .trash-panel, .settings-panel {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 20px 18px calc(var(--tab-h) + env(safe-area-inset-bottom) + 18px);
  scrollbar-width: none;
}
.note-list::-webkit-scrollbar, .trash-panel::-webkit-scrollbar, .settings-panel::-webkit-scrollbar { display: none; }
.hidden { display: none !important; }

.item {
  position: relative;
  margin: 0 0 6px;
  border-radius: var(--radius);
  touch-action: pan-y;
  user-select: none;
}
.item-card {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 0px 0px minmax(0, 1fr) 0px;
  align-items: start;
  column-gap: 0;
  min-height: 45px;
  border-radius: var(--radius);
  transition: background .18s ease, transform .12s ease, box-shadow .18s ease, opacity .18s ease;
  background: transparent;
}
.item.active .item-card { background: rgba(255,255,255,.055); }
.item.swiping .item-card { transition: none; }
.item.dragging {
  z-index: 20;
  touch-action: none;
}
.item.dragging .item-card {
  background: rgba(255,255,255,.12);
  box-shadow: 0 18px 40px rgba(0,0,0,.42), inset 0 0 0 1px rgba(255,255,255,.08);
  transform: scale(1.015);
}
.item.drop-before { box-shadow: 0 -2px 0 rgba(255,255,255,.65); }
.item.drop-after { box-shadow: 0 2px 0 rgba(255,255,255,.65); }

.item-text {
  min-height: 45px;
  padding: 6px 0 7px;
  outline: none;
  color: var(--text);
  font-size: var(--font-note);
  line-height: 1.43;
  letter-spacing: .01em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
  caret-color: #fff;
}
.item-text:empty::before {
  content: attr(data-placeholder);
  color: rgba(255,255,255,.28);
}
.item-text[contenteditable="false"] { user-select: none; }

.kind-mark {
  display: none;
  width: 26px;
  padding: 6px 0 0;
  color: rgba(255,255,255,.46);
  font-size: 18px;
}
.item.nonmemo .item-card {
  grid-template-columns: 26px 0 minmax(0,1fr) 0px;
  margin: 18px 0 9px;
}
.item.nonmemo .kind-mark { display: block; }
.item.nonmemo .kind-mark::before { content: "◆"; }
.item.nonmemo .item-text {
  color: rgba(255,255,255,.64);
  font-size: 18px;
  line-height: 1.38;
  font-weight: 650;
  letter-spacing: .06em;
}
.item.nonmemo .item-card::after {
  content: "";
  position: absolute;
  left: 26px;
  right: 0;
  bottom: 2px;
  height: 1px;
  background: rgba(255,255,255,.12);
}

body.task-tab .item:not(.nonmemo) .item-card {
  grid-template-columns: 34px 0 minmax(0,1fr) 0px;
  column-gap: 2px;
}
.task-check {
  display: none;
  width: 26px;
  height: 26px;
  margin: 9px 6px 0 0;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,.46);
  background: transparent;
  padding: 0;
  position: relative;
}
body.task-tab .item:not(.nonmemo) .task-check { display: block; }
.item.done .task-check {
  border-color: rgba(255,255,255,.72);
  background: rgba(255,255,255,.82);
}
.item.done .task-check::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 3px;
  width: 8px;
  height: 14px;
  border: solid #000;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.item.done .item-text { color: rgba(255,255,255,.42); text-decoration: line-through; text-decoration-thickness: 1.5px; }

.eye-btn {
  display: none;
  width: 34px;
  height: 34px;
  margin: 5px 0 0 8px;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  font-size: 17px;
  padding: 0;
}
body.sensitive-tab .item:not(.nonmemo) .item-card {
  grid-template-columns: 0px 0px minmax(0,1fr) 42px;
}
body.sensitive-tab .item:not(.nonmemo) .eye-btn { display: block; }
.item.redacted .item-text {
  color: transparent;
  text-shadow: none;
  caret-color: transparent;
  position: relative;
}
.item.redacted .item-text::after {
  content: "";
  position: absolute;
  left: 0;
  right: 2px;
  top: 10px;
  bottom: 10px;
  min-height: 22px;
  border-radius: 8px;
  background: linear-gradient(90deg, #070707, #151515 42%, #050505);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05);
}
.item.redacted .eye-btn { opacity: .78; }

.swipe-bg {
  position: absolute;
  inset: 3px 0;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  padding: 0 18px;
  z-index: 1;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .04em;
  opacity: 0;
  transition: opacity .12s ease;
  pointer-events: none;
}
.swipe-bg.left { justify-content: flex-start; background: rgba(120,120,128,.28); }
.swipe-bg.right { justify-content: flex-end; background: rgba(255,69,58,.36); }
.item.swipe-right .swipe-bg.left, .item.swipe-left .swipe-bg.right { opacity: 1; }

.empty-note {
  min-height: 120px;
  display: flex;
  align-items: flex-start;
  color: rgba(255,255,255,.35);
  font-size: var(--font-note);
  line-height: 1.45;
  padding-top: 10px;
}

.bottom-tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  overflow-x: auto;
  background: rgba(9,9,9,.80);
  border-top: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(20px);
  scrollbar-width: none;
  z-index: 50;
}
.bottom-tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  flex: 0 0 auto;
  min-width: 72px;
  height: 54px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.76);
  padding: 6px 8px;
  display: grid;
  grid-template-rows: 18px 1fr;
  place-items: center;
  gap: 2px;
}
.tab-btn .num { font-size: 14px; font-weight: 800; color: rgba(255,255,255,.56); }
.tab-btn .label { font-size: 11px; font-weight: 650; white-space: nowrap; }
.tab-btn.active {
  background: rgba(255,255,255,.18);
  color: #fff;
  border-color: rgba(255,255,255,.18);
}

.trash-toolbar, .settings-card {
  border-radius: 22px;
  background: rgba(255,255,255,.075);
  border: 1px solid rgba(255,255,255,.08);
  padding: 14px;
  margin-bottom: 14px;
}
.trash-toolbar {
  position: sticky;
  top: 0;
  z-index: 3;
  backdrop-filter: blur(20px);
}
.toolbar-title { font-size: 18px; font-weight: 750; margin-bottom: 12px; }
.toolbar-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pill-btn, .settings-card button, .file-label {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  color: #fff;
  min-height: 38px;
  padding: 8px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}
.pill-btn.danger { background: rgba(255,69,58,.22); border-color: rgba(255,69,58,.36); }
.trash-item {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 8px;
  align-items: start;
  border-bottom: 1px solid rgba(255,255,255,.07);
  padding: 12px 0;
}
.trash-item input { width: 22px; height: 22px; margin: 4px 0 0; accent-color: #fff; }
.trash-text { font-size: 19px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.trash-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }

.settings-panel { padding-top: 18px; }
.settings-card h2 {
  font-size: 18px;
  margin: 0 0 10px;
}
.settings-card p {
  margin: 8px 0 0;
  color: rgba(255,255,255,.58);
  font-size: 14px;
  line-height: 1.55;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid rgba(255,255,255,.07);
}
.toggle-row:first-of-type { border-top: 0; }
.switch {
  position: relative;
  width: 52px;
  height: 32px;
  flex: 0 0 auto;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255,255,255,.18);
  transition: .2s;
  border-radius: 999px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 28px;
  width: 28px;
  left: 2px;
  top: 2px;
  background: white;
  transition: .2s;
  border-radius: 50%;
}
.switch input:checked + .slider { background: rgba(48,209,88,.56); }
.switch input:checked + .slider:before { transform: translateX(20px); }
.file-input { display: none; }
textarea.export-box {
  width: 100%;
  min-height: 130px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.32);
  color: #fff;
  padding: 12px;
  outline: none;
  resize: vertical;
  font-size: 13px;
  line-height: 1.45;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  max-width: min(86vw, 420px);
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  background: rgba(30,30,30,.92);
  color: #fff;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  padding: 11px 16px;
  font-size: 14px;
  transition: opacity .18s ease, transform .18s ease;
  backdrop-filter: blur(18px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 380px) {
  :root { --font-note: 21px; --top-h: 76px; }
  .topbar { padding-left: 14px; padding-right: 14px; grid-template-columns: 48px 1fr 48px; }
  .round-btn { width: 43px; height: 43px; }
  .note-list, .trash-panel, .settings-panel { padding-left: 16px; padding-right: 16px; }
  .tab-btn { min-width: 68px; }
}
