:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #16181d;
  --ink-2: #4a505c;
  --muted: #5f6673;
  --line: #e3e6eb;
  --line-2: #d3d8df;
  --accent: #3b5bdb;
  --accent-ink: #ffffff;
  --accent-soft: #edf1ff;
  --ok: #1e7a46;
  --warn: #9a5b00;
  --danger: #c0352b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 16px rgba(16, 24, 40, 0.06);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317; --panel: #1a1d23; --ink: #eceef2; --ink-2: #c3c8d1; --muted: #9aa1ad; --line: #2a2f37; --line-2: #363c46;
    --accent: #7c95ff; --accent-ink: #0d1020; --accent-soft: #1f2640; --ok: #4fc183; --warn: #e3a64a; --danger: #ff7b70;
    --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); color: var(--ink); cursor: pointer;
  font-weight: 500; text-decoration: none; white-space: nowrap; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg); }
.btn:disabled { opacity: 0.6; cursor: progress; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 500; color: var(--ink-2); font-size: 13px; }
.field input, .field textarea, .field select, .input {
  height: 38px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel);
}
.field textarea { height: auto; padding: 10px 12px; min-height: 90px; resize: vertical; }
.hint { color: var(--muted); font-size: 13px; }

/* Shell */
.topbar { height: 56px; display: flex; align-items: center; gap: 16px; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.logo { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--ink); }
.logo b { font-size: 16px; }
.logo span { color: var(--muted); font-size: 12px; }
.topbar .spacer { flex: 1; }
.lang { height: 32px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); padding: 0 8px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 20px 80px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 20px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 18px; }
.site-tile { padding: 18px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); }
.site-tile:hover { border-color: var(--accent); }
.site-tile .domain { color: var(--muted); }

/* Site page */
.site-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.site-head h1 { font-size: 22px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.status.pending::before { background: var(--warn); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 11px; text-align: center; margin-left: 4px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 180px; }
.list .title { font-weight: 600; }
.list .sub { color: var(--muted); font-size: 13px; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pill.muted { background: var(--bg); color: var(--muted); }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.media-item { overflow: hidden; display: flex; flex-direction: column; }
.media-item .thumb { aspect-ratio: 4 / 3; background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.media-item .thumb img, .media-item .thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-item .meta { padding: 8px 10px; font-size: 12px; color: var(--muted); word-break: break-all; }
.media-item .actions { display: flex; gap: 4px; padding: 0 6px 8px; }
.drop { border: 2px dashed var(--line-2); border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted); margin-bottom: 16px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }

.msg { padding: 14px 16px; }
.msg dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 8px 0 0; }
.msg dt { color: var(--muted); }
.msg dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.msg.unread { border-left: 3px solid var(--accent); }

.empty { padding: 40px; text-align: center; color: var(--muted); }
.banner { padding: 12px 16px; border-radius: 8px; background: var(--accent-soft); color: var(--ink); margin-bottom: 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner.warn { background: #fff4e0; color: #5c3900; }
@media (prefers-color-scheme: dark) { .banner.warn { background: #3a2c12; color: #ffd99a; } }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
pre.dns { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login h1 { font-size: 20px; margin: 18px 0 18px; }
.login .error { color: var(--danger); min-height: 20px; margin: 4px 0 10px; font-size: 13px; }

/* Dialog */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 22px; background: var(--panel); color: var(--ink); width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10, 12, 18, 0.45); }
dialog h2 { font-size: 17px; margin-bottom: 14px; }

#ms-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: 0.2s;
  background: #16181d; color: #fff; padding: 10px 16px; border-radius: 8px; max-width: min(560px, calc(100vw - 32px)); z-index: 1000; box-shadow: var(--shadow); }
#ms-toast.show { opacity: 1; transform: translate(-50%, 0); }
#ms-toast[data-kind="error"] { background: var(--danger); color: #fff; }

@media (max-width: 640px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .logo span { display: none; }
  .wrap { padding: 18px 12px 60px; }
}
