:root {
  --bg: #F2F2F4;
  --card: #fff;
  --text: #111111;
  --sub: #5F5F66;
  --line: #ECECEF;
  --fill: #E6E6EA;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 14px rgba(0, 0, 0, .045);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, "SF Pro Text", Inter, Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a, button, input, label, .logo-tile { touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: .3; cursor: default; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

.app {
  max-width: 480px; margin: 0 auto;
  padding: 0 16px calc(16px + env(safe-area-inset-bottom));
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
}
main { flex: 1; }

/* Header */
.top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 0 6px;
}
.logo-tile {
  width: 48px; height: 48px; flex: none;
  border-radius: 14px; background: #fff; box-shadow: var(--shadow);
  display: grid; place-items: center;
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
.logo { filter: grayscale(1); border-radius: 8px; object-fit: contain; -webkit-user-drag: none; }
.brand { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.b1 { font-size: 13px; font-weight: 600; color: var(--sub); }
.b2 { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow);
  display: grid; place-items: center;
}

/* Press feedback */
.press, .icon-btn, .btn, .ib, .row, .logo-tile { transition: transform .12s ease-out; }
.press:active, .icon-btn:active, .btn:active, .ib:active, .logo-tile:active { transform: scale(.97); }
.row:active { transform: scale(.985); }

/* Titles */
.title { font-size: 34px; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; margin: 18px 0 14px; }
.sub { color: var(--sub); font-size: 15px; }

/* Search */
.search { position: relative; margin-bottom: 16px; }
.search .ic { position: absolute; left: 12px; top: 12px; width: 20px; height: 20px; color: var(--sub); pointer-events: none; }
.search input {
  width: 100%; height: 44px; border: 0; border-radius: 12px;
  background: var(--fill); padding: 0 12px 0 40px; font-size: 17px;
  -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--sub); }
.search input:focus { outline: none; box-shadow: 0 0 0 2px var(--text); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* Folder grid */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card {
  display: flex; flex-direction: column; gap: 4px;
  min-height: 128px; padding: 16px;
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
}
.ftile {
  width: 44px; height: 44px; border-radius: 12px; margin-bottom: auto;
  background: var(--bg); display: grid; place-items: center;
}
.cname {
  margin-top: 12px; font-size: 16px; font-weight: 650; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
}
.ccount { font-size: 13px; color: var(--sub); }
.empty { text-align: center; color: var(--sub); padding: 40px 0; }

/* Folder page */
.back {
  display: inline-flex; align-items: center; gap: 2px;
  min-height: 44px; margin: 6px 0 0 -6px; padding-right: 10px;
  font-size: 17px; font-weight: 500;
}
.fhead { display: flex; align-items: center; gap: 14px; margin: 8px 0 18px; }
.fhead .ftile { width: 56px; height: 56px; border-radius: 16px; margin: 0; background: #fff; box-shadow: var(--shadow); }
.fhead .ftile .ic { width: 28px; height: 28px; }
.fhead h1 { font-size: 26px; line-height: 1.2; font-weight: 800; letter-spacing: -.02em; overflow-wrap: anywhere; }

.group { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.row, .arow { position: relative; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 14px; }
.row + .row::before, .arow + .arow::before {
  content: ""; position: absolute; top: 0; left: 62px; right: 0;
  border-top: 1px solid var(--line);
}
.arow + .arow::before { left: 14px; }
.ltile {
  width: 36px; height: 36px; flex: none; border-radius: 10px;
  background: var(--text); color: #fff; display: grid; place-items: center;
}
.ltile .ic { width: 20px; height: 20px; }
.ltext { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lname { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lsub { font-size: 13px; color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arrow { width: 18px; height: 18px; color: var(--sub); }
.hint { text-align: center; color: var(--sub); font-size: 13px; margin: 14px 0 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 18px; border-radius: 12px;
  font-size: 16px; font-weight: 600; white-space: nowrap;
}
.btn .ic { width: 18px; height: 18px; }
.primary { background: var(--text); color: #fff; }
.secondary { background: #fff; color: var(--text); box-shadow: inset 0 0 0 1px #DADADF; }
.ghost { min-height: 44px; padding: 0 12px; background: #fff; box-shadow: var(--shadow); font-size: 15px; }
.block { width: 100%; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 80;
  padding: 10px 16px; border-radius: 999px; background: var(--text); color: #fff; font-size: 14px; font-weight: 500;
  opacity: 0; transform: translate(-50%, 10px); pointer-events: none;
  transition: opacity .2s ease-out, transform .2s ease-out;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* Bottom sheet */
.backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .4);
  opacity: 0; transition: opacity .22s ease-out; touch-action: none;
}
.backdrop.on { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51;
  max-width: 480px; max-height: 92vh; margin: 0 auto; overflow-y: auto; overscroll-behavior: contain;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .24s var(--ease);
}
.sheet.on { transform: translateY(0); }
.anim { will-change: transform, opacity; }
.grab { width: 36px; height: 5px; border-radius: 3px; background: #D6D6DB; margin: 0 auto 6px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h2 { font-size: 20px; font-weight: 700; }
.sheet-head .icon-btn { width: 36px; height: 36px; background: var(--bg); box-shadow: none; position: relative; }
.sheet-head .icon-btn::after { content: ""; position: absolute; inset: -4px; }
.sheet-head .icon-btn .ic { width: 18px; height: 18px; }

/* Share */
.qr-wrap {
  width: 248px; height: 248px; margin: 4px auto 0; padding: 4px;
  border-radius: 18px; background: #fff; box-shadow: inset 0 0 0 1px var(--line);
}
.qr, .qr-ph { display: block; width: 240px; height: 240px; border-radius: 12px; }
.qr-ph { background: var(--bg); }
.center { text-align: center; }
.share-note { margin: 14px 0 12px; }
.pill {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 4px 4px 16px; border-radius: 999px; background: var(--bg);
}
.pill-url { flex: 1; min-width: 0; font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill .btn { min-height: 40px; min-width: 84px; padding: 0 14px; border-radius: 999px; font-size: 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }

/* Login */
.login {
  position: fixed; inset: 0; z-index: 60; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  opacity: 0; transform: scale(.98); transition: opacity .2s ease-out, transform .2s ease-out;
}
.login.on { opacity: 1; transform: none; }
.close-tl { position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 16px; }
.login-box { width: 100%; max-width: 340px; text-align: center; }
.big-logo {
  width: 96px; height: 96px; margin: 0 auto 18px; border-radius: 26px;
  background: #fff; box-shadow: var(--shadow); display: grid; place-items: center;
}
.login-box h2 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.login-box .sub { margin: 4px 0 22px; }
.field {
  display: block; width: 100%; height: 50px; padding: 0 14px;
  border: 0; border-radius: 12px; background: #fff; box-shadow: inset 0 0 0 1px #DADADF;
  font-size: 17px; -webkit-appearance: none; appearance: none;
}
.field:focus { outline: none; box-shadow: inset 0 0 0 2px var(--text); }
.login-box .btn { margin-top: 12px; }
.err { min-height: 20px; margin-top: 8px; font-size: 14px; font-weight: 500; color: #B3261E; }

/* Forms in sheets */
.form label { display: block; font-size: 13px; font-weight: 600; color: var(--sub); margin: 10px 0 6px; }
.form .field { background: var(--bg); box-shadow: none; }
.form .field:focus { box-shadow: inset 0 0 0 2px var(--text); }
.form .btn { margin-top: 14px; }

/* Admin */
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.actions .btn { padding: 0 8px; }
.actions .primary { grid-column: 1 / -1; }
.note { font-size: 13px; color: var(--sub); background: #fff; border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow); }
.status { font-size: 13px; font-weight: 600; margin: 0 0 16px 4px; }
.arow { gap: 2px; padding: 6px 4px 6px 14px; }
.aname { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 44px; justify-content: center; padding-right: 6px; }
.ib { width: 40px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 10px; color: var(--text); }
.ib .ic { width: 19px; height: 19px; }
.ib:active { background: var(--bg); }

.foot { text-align: center; color: var(--sub); font-size: 13px; font-weight: 600; letter-spacing: .04em; padding: 28px 0 8px; }

/* View transitions (transform + opacity only) */
.enter { animation: fade .2s ease-out both; }
.push { animation: push .22s ease-out both; }
.shake { animation: shake .32s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
@keyframes push { from { opacity: 0; transform: translateX(18px); } }
@keyframes shake {
  20% { transform: translateX(-8px); } 40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); } 80% { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}
