:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #6b7079;
  --line: #e4e4e0;
  --line-strong: #d3d3ce;
  --accent: #1f3a5f;
  --accent-hover: #172c48;
  --row-hover: #fafaf8;
  --err: #a12a2a;
  --ok: #2f5d3a;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "tnum";
}
#app { min-height: 100vh; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

/* Top bar */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1200px; margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 32px; }
.wordmark { font-weight: 600; font-size: 15px; letter-spacing: 0.01em; white-space: nowrap; }
.wordmark span { color: var(--muted); font-weight: 400; margin-left: 8px; padding-left: 8px; border-left: 1px solid var(--line-strong); }
.nav { display: flex; gap: 4px; height: 100%; }
.nav button { background: none; border: 0; padding: 0 12px; height: 100%; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.nav button:hover { color: var(--text); }
.nav button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
.user { margin-left: auto; display: flex; align-items: center; gap: 16px; white-space: nowrap; }
.user-name { color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; height: 36px; padding: 0 14px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 4px; cursor: pointer; font-weight: 500; }
.btn:hover { border-color: #b9b9b3; }
.btn.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.block { width: 100%; height: 40px; margin-top: 20px; }
.btn:focus-visible, .link:focus-visible, .in:focus-visible, .nav button:focus-visible, .folders button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }
.link:hover { text-decoration: underline; }
.link.strong { color: var(--text); font-weight: 500; text-align: left; }

/* Sign in */
.signin-wrap { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 96px 20px 40px; }
.signin { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 32px; }
.signin h1 { font-size: 18px; margin-bottom: 24px; }
.f { display: block; font-size: 13px; font-weight: 500; margin: 14px 0 6px; }
.in { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 4px; background: #fff; font: inherit; font-size: 16px; color: var(--text); }
.in:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(31, 58, 95, 0.12); }
.err { color: var(--err); background: #fbf2f2; border: 1px solid #efd6d6; border-radius: 4px; padding: 8px 12px; margin: 0 0 8px; font-size: 13px; }
.ok { color: var(--ok); font-size: 13px; }

/* Page */
.wrap { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 32px 24px 48px; }
.page-h { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; min-height: 30px; }
.page-h h1 { font-size: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

.layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.folders { display: flex; flex-direction: column; gap: 2px; }
.folders button { display: flex; justify-content: space-between; align-items: center; width: 100%; background: none; border: 0; border-radius: 4px; padding: 8px 10px; cursor: pointer; text-align: left; color: var(--text); }
.folders button:hover { background: #efefec; }
.folders button.on { background: #e9ecf1; color: var(--accent); font-weight: 500; }
.count { color: var(--muted); font-size: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-h h2 { font-size: 14px; }
.card-tools { display: flex; align-items: center; gap: 12px; }
.drop.over { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.hidden-input { display: none; }

/* Tables */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--line); background: #fbfbfa; white-space: nowrap; }
td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--row-hover); }
td.name { font-weight: 500; }
.num { text-align: right; white-space: nowrap; }
.actions { text-align: right; white-space: nowrap; }
.actions .link + .link { margin-left: 16px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* Preview */
.back { position: fixed; inset: 0; background: rgba(15, 18, 24, 0.45); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 10; }
.modal { background: var(--surface); border-radius: 6px; width: min(960px, 100%); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); }
.modal-h { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-t { min-width: 0; }
.modal-t h2 { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-a { display: flex; gap: 8px; flex-shrink: 0; }
.preview-frame { width: 100%; height: 72vh; border: 0; background: #f2f2f0; }
.preview-img { max-width: 100%; max-height: 72vh; display: block; margin: 0 auto; padding: 16px; }
.preview-text { margin: 0; padding: 20px; max-height: 72vh; overflow: auto; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.preview-none { padding: 40px 20px; text-align: center; }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; }

@media (max-width: 760px) {
  .top-in { padding: 0 16px; gap: 16px; }
  .wordmark span, .user-name { display: none; }
  .nav button { padding: 0 8px; }
  .wrap { padding: 20px 16px 32px; }
  .layout { grid-template-columns: 1fr; gap: 16px; }
  .folders { flex-direction: row; overflow-x: auto; gap: 4px; }
  .folders button { width: auto; white-space: nowrap; gap: 8px; }
  .col-folder, .col-by { display: none; }
  th, td { padding-left: 12px; padding-right: 12px; }
  .signin-wrap { padding-top: 48px; }
  .signin { padding: 24px; }
}
