/* ============================================================
   PixOffice — core design system
   ============================================================ */

:root {
  --bg: #eef0f4;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef1f5;
  --border: #dfe3e9;
  --border-strong: #c8cfd8;
  --text: #171b22;
  --text-2: #4a5462;
  --muted: #78828f;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --accent-ink: #3730a3;
  --danger: #dc2626;
  --ok: #15803d;
  --warn: #b45309;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-2: 0 4px 12px rgba(16, 24, 40, .08), 0 12px 32px rgba(16, 24, 40, .12);
  --shadow-3: 0 20px 60px rgba(16, 24, 40, .22);
  --topbar-h: 48px;
  --statusbar-h: 28px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: #c7d2fe; }

/* ---------- scrollbars ---------- */
*::-webkit-scrollbar { width: 12px; height: 12px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #c3cad4; border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #a4aebc; background-clip: content-box; border: 3px solid transparent; }

/* ============================================================
   Launcher
   ============================================================ */
body.launcher { display: flex; flex-direction: column; background:
  radial-gradient(1200px 500px at 80% -10%, #e2e6ff 0%, transparent 60%),
  radial-gradient(900px 400px at 0% 0%, #e6f5ff 0%, transparent 55%), var(--bg); }

.launch-header {
  height: 66px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.72); backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { display: grid; place-items: center; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; letter-spacing: -.2px; }
.brand-text em { font-style: normal; font-size: 11.5px; color: var(--muted); }
.launch-actions { display: flex; align-items: center; gap: 10px; }
.search { display: flex; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 0 12px; height: 34px; width: 280px; color: var(--muted); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { border: 0; outline: 0; background: transparent; width: 100%; font-size: 13px; }

.launch-main { flex: 1; overflow: auto; padding: 34px 28px 40px; }
.launch-main > * { max-width: 1120px; margin-inline: auto; }
.hero { text-align: center; margin-bottom: 30px; }
.hero h1 { font-size: 30px; margin: 0 0 8px; letter-spacing: -.6px; }
.hero p { margin: 0 auto; max-width: 620px; color: var(--text-2); line-height: 1.55; }

.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.app-card {
  display: flex; align-items: flex-start; gap: 14px; padding: 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-1);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.app-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.app-icon { flex: none; width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center;
  color: #fff; background: var(--accent); box-shadow: 0 6px 14px color-mix(in srgb, var(--accent) 34%, transparent); }
.app-icon svg { width: 23px; height: 23px; }
.app-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.app-name { font-weight: 650; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.app-name em { font-style: normal; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--accent); background: var(--accent-soft); padding: 2px 7px; border-radius: 999px; }
.app-desc { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.app-go { margin-left: auto; color: var(--border-strong); align-self: center; }
.app-card:hover .app-go { color: var(--accent); }

.recent { margin-top: 34px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-head h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 0; font-weight: 650; }
.recent-list { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.recent-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.recent-item:last-child { border-bottom: 0; }
.recent-item:hover { background: var(--surface-2); }
.recent-name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46%; }
.recent-app { font-size: 12px; color: var(--muted); }
.recent-time { margin-left: auto; font-size: 12px; color: var(--muted); }
.dot-badge { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }

.launch-footer { flex: none; display: flex; align-items: center; gap: 10px; justify-content: center;
  padding: 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }
.launch-footer a { color: var(--accent); }
.launch-footer .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--border-strong); }

/* ============================================================
   App shell
   ============================================================ */
body.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; background: var(--bg); }

.topbar {
  flex: none; height: var(--topbar-h); display: flex; align-items: center; gap: 8px; padding: 0 10px;
  background: var(--surface); border-bottom: 1px solid var(--border); z-index: 30;
}
.topbar .brand-mini { display: flex; align-items: center; gap: 8px; padding: 0 8px 0 4px; margin-right: 2px; }
.topbar .brand-mini svg { border-radius: 7px; }
.topbar .brand-mini span { font-weight: 650; font-size: 13.5px; letter-spacing: -.2px; }
.doc-title {
  border: 1px solid transparent; background: transparent; padding: 5px 9px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 13.5px; min-width: 120px; max-width: 320px; text-overflow: ellipsis;
}
.doc-title:hover { border-color: var(--border); }
.doc-title:focus { border-color: var(--accent); background: var(--surface); outline: 0; box-shadow: 0 0 0 3px var(--accent-soft); }
.sep { width: 1px; height: 22px; background: var(--border); margin: 0 3px; flex: none; }
.spacer { flex: 1; }
.save-state { font-size: 11.5px; color: var(--muted); padding: 0 6px; white-space: nowrap; }
.save-state.saved { color: var(--ok); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 12.5px; font-weight: 550;
  cursor: pointer; white-space: nowrap; transition: background .13s, border-color .13s, box-shadow .13s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(.5px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #443bd6; border-color: #443bd6; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn-icon { width: 30px; padding: 0; justify-content: center; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-danger { color: var(--danger); }

.icon-btn { width: 26px; height: 26px; display: grid; place-items: center; border: 0; background: transparent;
  color: var(--muted); border-radius: 6px; cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.on { background: var(--accent-soft); color: var(--accent-ink); }

.select, .input, .textarea {
  height: 30px; padding: 0 9px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 12.5px; outline: 0;
}
.select:focus, .input:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { height: auto; padding: 7px 9px; resize: vertical; font-family: inherit; }

.toolbar {
  flex: none; display: flex; align-items: center; gap: 5px; padding: 6px 10px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-wrap: wrap; row-gap: 5px; z-index: 20;
}
.toolbar.group { background: var(--surface-2); }
.tb-group { display: flex; align-items: center; gap: 3px; padding-right: 7px; margin-right: 3px; border-right: 1px solid var(--border); }
.tb-group:last-child { border-right: 0; }
.tb-btn { min-width: 28px; height: 28px; padding: 0 7px; display: inline-flex; align-items: center; justify-content: center;
  gap: 5px; border: 1px solid transparent; background: transparent; border-radius: 6px; cursor: pointer;
  color: var(--text-2); font-size: 12.5px; }
.tb-btn:hover { background: var(--surface-3); color: var(--text); }
.tb-btn.on { background: var(--accent-soft); color: var(--accent-ink); border-color: #d9dcfb; }
.tb-btn svg { width: 15px; height: 15px; }
.tb-btn .lbl { font-size: 12.5px; }
.tb-select { height: 28px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); font-size: 12.5px; padding: 0 4px; outline: 0; }
.tb-color { width: 28px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer; }
.tb-color::-webkit-color-swatch-wrapper { padding: 2px; }
.tb-color::-webkit-color-swatch { border: 0; border-radius: 4px; }
.tb-range { width: 92px; accent-color: var(--accent); }

/* ---------- app body layouts ---------- */
.app-body { flex: 1; display: flex; min-height: 0; overflow: hidden; }
.app-body.col { flex-direction: column; }
.pane { min-width: 0; min-height: 0; }
.sidebar {
  flex: none; width: 240px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar.right { border-right: 0; border-left: 1px solid var(--border); width: 268px; }
.side-head { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.side-head h3 { margin: 0; font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 650; }
.side-list { flex: 1; overflow: auto; padding: 6px; }
.side-item { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 12.5px; color: var(--text-2); }
.side-item:hover { background: var(--surface-2); }
.side-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.side-item .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .count { font-size: 11px; color: var(--muted); }
.statusbar {
  flex: none; height: var(--statusbar-h); display: flex; align-items: center; gap: 14px; padding: 0 12px;
  background: var(--surface); border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted);
}
.statusbar .spacer { flex: 1; }
.statusbar b { font-weight: 600; color: var(--text-2); }

/* ============================================================
   Overlays: toast, modal, menu
   ============================================================ */
.toast-host { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: #111827; color: #f9fafb; padding: 9px 14px; border-radius: 9px; font-size: 13px; box-shadow: var(--shadow-2);
  animation: toast-in .22s ease; max-width: 340px; display: flex; align-items: center; gap: 8px;
}
.toast.ok { background: #14532d; } .toast.err { background: #7f1d1d; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

.modal-host { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center;
  background: rgba(15, 20, 30, .38); backdrop-filter: blur(2px); padding: 20px; }
.modal-host[hidden] { display: none; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-3); width: min(520px, 100%);
  max-height: 86vh; display: flex; flex-direction: column; overflow: hidden; animation: modal-in .18s ease; }
.modal.wide { width: min(760px, 100%); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98) } to { opacity: 1; transform: none } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 15px; }
.modal-body { padding: 16px; overflow: auto; }
.modal-body p { margin: 0 0 12px; color: var(--text-2); line-height: 1.55; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.field .input, .field .select, .field .textarea { width: 100%; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.45; }

.menu-host { position: absolute; z-index: 400; }
.menu {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-2);
  padding: 5px; min-width: 190px; animation: modal-in .13s ease;
}
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 7px 10px;
  border: 0; background: transparent; border-radius: 6px; cursor: pointer; font-size: 12.5px; }
.menu-item:hover { background: var(--surface-3); }
.menu-item.danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 2px; }
.menu-label { padding: 6px 10px 3px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 650; }

/* ============================================================
   Shared bits
   ============================================================ */
.empty-state { display: grid; place-items: center; height: 100%; text-align: center; color: var(--muted); padding: 40px; }
.empty-state h3 { color: var(--text); margin: 12px 0 6px; font-size: 16px; }
.empty-state p { margin: 0 0 16px; font-size: 13px; max-width: 380px; line-height: 1.55; }

.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.data { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.data th, table.data td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; vertical-align: top; }
table.data thead th { background: var(--surface-3); font-weight: 650; position: sticky; top: 0; z-index: 2; white-space: nowrap; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12px; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.ok { background: #dcfce7; color: #15803d; }
.badge.err { background: #fee2e2; color: #b91c1c; }
.badge.info { background: #e0e7ff; color: #4338ca; }
.badge.warn { background: #fef3c7; color: #b45309; }

.kbd { display: inline-block; padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 4px; font-family: var(--mono); font-size: 11px; background: var(--surface-2); color: var(--text-2); }
