:root {
  --blue: #007AFD; --folder: #3B9DF0; --ink: #1D1D1F; --muted: #6E6E73; --line: rgba(0,0,0,.09); --line-strong: rgba(0,0,0,.16);
  --desk: #E9EBEF; --win: #FFFFFF; --side: #F3F3F5; --bar: #FBFBFC; --hover: rgba(0,0,0,.05); --danger: #D70015;
  --font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #F5F5F7; --muted: #A1A1A6; --line: rgba(255,255,255,.1); --line-strong: rgba(255,255,255,.2);
    --desk: #111113; --win: #1E1E20; --side: #29292C; --bar: #252528; --hover: rgba(255,255,255,.07); --danger: #FF453A; }
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--desk); color: var(--ink); font: 400 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }

.folder { display: block; width: 100%; height: auto; }
.f-back, .f-front { fill: var(--folder); }
.f-back { filter: brightness(.8); }
.f-shine { fill: #fff; opacity: .14; }

.window { display: grid; grid-template-columns: 208px minmax(0, 1fr); width: min(1240px, calc(100vw - 48px)); height: calc(100vh - 48px); height: calc(100dvh - 48px); margin: 24px auto; background: var(--win); border-radius: 13px; overflow: hidden; box-shadow: 0 0 0 .5px var(--line-strong), 0 22px 60px rgba(0,0,0,.17); }
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 10px 12px; }
.lights { display: flex; gap: 8px; padding: 0 8px 22px; }
.lights i { width: 12px; height: 12px; border-radius: 50%; background: #FF5F57; }
.lights i:nth-child(2) { background: #FEBC2E; }
.lights i:nth-child(3) { background: #28C840; }
.side-title { margin: 0; padding: 0 10px 6px; color: var(--muted); font-size: 11.5px; font-weight: 600; }
#nav a { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; border-radius: 7px; font-size: 13.5px; }
#nav a:hover { background: var(--hover); }
#nav a.active { background: var(--line-strong); font-weight: 500; }
#new-count { min-width: 19px; padding: 1px 6px; border-radius: 10px; background: var(--blue); color: #fff; font-size: 11.5px; font-weight: 600; text-align: center; }
.side-exit { margin-top: auto; padding: 6px 10px; border: 0; border-radius: 7px; background: none; color: var(--muted); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.side-exit:hover { background: var(--hover); color: var(--ink); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.bar { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 8px 14px; background: var(--bar); border-bottom: 1px solid var(--line); }
.nav-btn { width: 30px; height: 30px; flex: none; border: 0; border-radius: 7px; background: none; color: var(--ink); font-size: 22px; line-height: 1; padding-bottom: 3px; cursor: pointer; }
.nav-btn:hover:not(:disabled) { background: var(--hover); }
.nav-btn:disabled { opacity: .28; cursor: default; }
.crumbs { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; font-size: 14.5px; font-weight: 600; overflow: hidden; white-space: nowrap; }
.crumbs a { color: var(--muted); font-weight: 500; }
.crumbs a:hover { color: var(--ink); }
.crumbs i { color: var(--muted); font-style: normal; font-weight: 400; }
.crumbs span { overflow: hidden; text-overflow: ellipsis; }
.bar-actions { display: flex; gap: 8px; flex: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 30px; padding: 5px 12px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--win); color: var(--ink); font: 500 13px/1.25 var(--font); white-space: nowrap; cursor: pointer; transition: background .12s; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #0069DB; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 26px; padding: 3px 10px; font-size: 12.5px; }
.btn:focus-visible, .tile:focus-visible, #nav a:focus-visible, .nav-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.content { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; }
.status { padding: 6px 16px; border-top: 1px solid var(--line); background: var(--bar); color: var(--muted); font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(146px, 1fr)); gap: 6px; align-content: start; }
.tile { display: flex; flex-direction: column; align-items: center; padding: 14px 8px 12px; border-radius: 10px; text-align: center; min-width: 0; transition: background .12s; }
.tile:hover { background: var(--hover); }
.tile-icon { position: relative; display: block; width: 92px; margin-bottom: 8px; transition: transform .16s cubic-bezier(.2,.8,.2,1); }
.tile:hover .tile-icon { transform: translateY(-2px); }
.tile:active .tile-icon { transform: scale(.97); }
.tile-name { max-width: 100%; font-size: 13.5px; font-weight: 500; line-height: 1.25; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-sub { margin-top: 3px; color: var(--muted); font-size: 11.5px; line-height: 1.3; }
.badge { position: absolute; top: 2px; right: -5px; min-width: 21px; height: 21px; padding: 0 6px; border-radius: 11px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 600; line-height: 21px; box-shadow: 0 0 0 2px var(--win); }
.badge.dot { min-width: 13px; width: 13px; height: 13px; padding: 0; top: 7px; right: -2px; }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100%; padding: 32px 16px; text-align: center; color: var(--muted); }
.empty .folder { width: 92px; margin-bottom: 16px; opacity: .92; }
.empty h2 { margin: 0 0 6px; color: var(--ink); font-size: 17px; font-weight: 600; }
.empty p { margin: 0 0 16px; max-width: 42ch; }

.linkbar { display: flex; align-items: center; gap: 8px; padding: 11px 13px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 10px; flex-wrap: wrap; }
.linkbar-text { flex: 1 1 280px; min-width: 0; }
.linkbar-text span { display: block; color: var(--muted); font-size: 11.5px; }
code { font: 12.5px/1.4 ui-monospace, Menlo, monospace; overflow-wrap: anywhere; }

.detail { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 26px; align-items: start; max-width: 1020px; margin: 0 auto; }
.detail-main { min-width: 0; }
h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.text-block { margin-bottom: 22px; }
.text-block p { margin: 0; max-width: 68ch; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.55; }
.file-group { margin-bottom: 22px; }
.file-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.file-list li { display: flex; align-items: center; gap: 11px; padding: 9px 12px; }
.file-list li + li { border-top: 1px solid var(--line); }
.file-icon { display: flex; align-items: flex-end; justify-content: center; width: 30px; height: 36px; flex: none; padding-bottom: 5px; border-radius: 4px; background: var(--hover); box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); font-size: 8.5px; font-weight: 700; }
.file-meta { flex: 1; min-width: 0; }
.file-title { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta small { color: var(--muted); font-size: 12px; }
.detail-side { position: sticky; top: 0; padding: 15px; border-radius: 10px; background: var(--side); }
dl { margin: 0; }
.info-row { padding: 0 0 11px; }
dt { color: var(--muted); font-size: 11.5px; }
dd { margin: 0; overflow-wrap: anywhere; }
.fetch { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); justify-items: start; }
.fetch span { color: var(--muted); font-size: 11.5px; }
.notice { margin: 0 0 18px; padding: 10px 12px; border-radius: 8px; background: var(--hover); }
.muted { color: var(--muted); }

.sheet { width: min(430px, calc(100vw - 32px)); padding: 22px; border: 0; border-radius: 13px; background: var(--win); color: var(--ink); box-shadow: 0 0 0 .5px var(--line-strong), 0 30px 90px rgba(0,0,0,.34); }
.sheet.wide { width: min(1080px, calc(100vw - 32px)); }
.sheet::backdrop { background: rgba(0,0,0,.28); }
.sheet h2 { margin: 0 0 14px; font-size: 16px; font-weight: 600; }
.sheet-text { margin: 0; color: var(--muted); }
.sheet-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.fields { display: grid; gap: 10px; align-content: start; }
.field { display: grid; gap: 4px; font-size: 12px; font-weight: 500; }
.field > span { color: var(--muted); }
input:not([type=file]):not([type=color]), textarea, select { width: 100%; padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--win); color: var(--ink); font: 400 13.5px/1.35 var(--font); }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: transparent; }
input[type=color] { width: 100%; height: 32px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--win); cursor: pointer; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.design { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; }
.preview { width: 100%; height: min(70vh, 660px); border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.error { margin: 10px 0 0; color: var(--danger); font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%); padding: 8px 14px; border-radius: 9px; background: rgba(30,30,32,.92); color: #fff; font-size: 13px; z-index: 20; white-space: nowrap; }

.login-body { display: grid; place-items: center; min-height: 100%; padding: 16px; }
.login { display: grid; gap: 11px; justify-items: center; width: min(330px, 100%); padding: 30px 26px 26px; border-radius: 13px; background: var(--win); box-shadow: 0 0 0 .5px var(--line-strong), 0 22px 60px rgba(0,0,0,.17); text-align: center; }
.login .folder { width: 68px; }
.login h1 { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.login button { width: 100%; padding: 8px; border: 0; border-radius: 7px; background: var(--blue); color: #fff; font: 500 14px var(--font); cursor: pointer; }
.login .hint { margin: 0; color: var(--muted); }

@media (max-width: 860px) {
  .detail { grid-template-columns: minmax(0, 1fr); }
  .detail-side { position: static; order: -1; }
  .design { grid-template-columns: minmax(0, 1fr); }
  .preview { height: 460px; }
}
@media (max-width: 640px) {
  body { background: var(--win); }
  .window { width: 100%; height: 100vh; height: 100dvh; margin: 0; border-radius: 0; box-shadow: none; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .side { flex-direction: row; align-items: center; padding: 8px 16px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .lights, .side-title { display: none; }
  #nav { display: flex; gap: 2px; }
  #nav a { white-space: nowrap; gap: 6px; }
  .side-exit { margin: 0 0 0 auto; white-space: nowrap; }
  .bar { flex-wrap: wrap; padding: 8px 16px; }
  .bar-actions { width: 100%; }
  .bar-actions .btn { flex: 1; }
  .content { padding: 14px 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(106px, 1fr)); }
  .tile-icon { width: 78px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
