:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #182230;
  --muted: #5d6b82;
  --line: #dbe4ee;
  --brand: #0b6efd;
  --brand-dark: #084db3;
  --danger: #c62828;
  --success: #1b7f4b;
  --warn: #8a5a00;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #eef4ff 0%, var(--bg) 220px);
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: rgba(255,255,255,0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.topbar nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.user { color: var(--muted); font-size: 0.95rem; }

.container { max-width: 1180px; margin: 28px auto; padding: 0 16px 40px; }
.page-title { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.page-title h1, .card h1, .card h2 { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; margin-top: 4px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(24, 34, 48, 0.04);
}
.card-narrow { max-width: 460px; margin: 40px auto; }
.layout { display: grid; grid-template-columns: 220px 1fr; gap: 18px; }
.sidebar { align-self: start; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.92rem; }

label { display: block; margin: 12px 0 6px; font-weight: 600; }
input, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #c8d5e5;
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: #fff;
}
textarea { resize: vertical; min-height: 280px; font-family: Consolas, "Courier New", monospace; line-height: 1.45; }
input:focus, textarea:focus { outline: 2px solid rgba(11,110,253,0.2); border-color: var(--brand); }
.preview {
  margin: 0;
  padding: 14px;
  border: 1px solid #c8d5e5;
  border-radius: 8px;
  background: #fff;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92rem;
  line-height: 1.5;
}

.btn {
  display: inline-block;
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn-small { padding: 7px 10px; font-size: 0.92rem; }
.btn-ghost { background: #eaf1fb; color: var(--brand-dark); }
.btn-ghost:hover { background: #dce9fa; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #a61f1f; }

.flash {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.flash.info { background: #eef5ff; border-color: #cfe0ff; color: #174ea6; }
.flash.success { background: #edf8f1; border-color: #cfe8d8; color: var(--success); }
.flash.error { background: #fdeeee; border-color: #f2cccc; color: var(--danger); }

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: #e9eef5;
  color: #334;
}
.badge-edit { background: #e7f3ec; color: var(--success); }
.badge-view, .badge-locked { background: #fff3e0; color: var(--warn); }
.badge-free { background: #e9f5ec; color: var(--success); }
.badge-mine { background: #e8f1ff; color: #1753b6; }

.folder-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.folder-list a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
}
.folder-list a.active, .folder-list a:hover { background: #eef4ff; text-decoration: none; }

.editor-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.editor-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.inline-form { display: inline; }
html:has(body.is-fullpage), body.is-fullpage { height: 100%; overflow: hidden; margin: 0; background: #eef2f7; }
body.is-fullpage .topbar { display: none !important; }
body.is-fullpage .container { max-width: none !important; width: 100%; height: 100vh; margin: 0; padding: 6px 8px 8px; display: flex; flex-direction: column; }
body.is-fullpage .footer { display: none !important; }
.oo-page { width: 100%; height: 100%; min-height: 0; display: flex; flex-direction: column; flex: 1 1 auto; }
.oo-topbar { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 2px 2px 6px; min-height: 34px; box-sizing: border-box; }
.oo-back { color: var(--muted); font-size: 0.92rem; white-space: nowrap; }
.oo-name { font-weight: 600; font-size: 0.98rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oo-editor { flex: 1 1 auto; display: block; width: 100%; min-height: 0; height: calc(100vh - 48px) !important; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.oo-editor > iframe { width: 100% !important; height: 100% !important; display: block; }
.oo-status {
  display: none;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #f2cf7a;
  background: #fff8e6;
  color: #7a5a00;
  font-size: 0.92rem;
}
.oo-status.is-visible { display: block; }
.oo-view-notice { margin: 8px 0; }.oo-status {
  display: none;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #f2cf7a;
  background: #fff8e6;
  color: #7a5a00;
  font-size: 0.92rem;
}
.oo-status.is-visible { display: block; }
.oo-view-notice { margin-bottom: 12px; }
.notes { margin: 0; padding-left: 20px; color: var(--muted); }
.notes li { margin-bottom: 8px; }
.footer { padding: 20px 16px 32px; text-align: center; color: var(--muted); font-size: 0.9rem; }
.danger-zone { border-color: #f0caca; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .page-title { flex-direction: column; }
  table { display: block; overflow-x: auto; }
}
.form-inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form-grid { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.form-grid label { display: grid; gap: 4px; font-size: 0.9rem; color: var(--muted); }
.form-grid input, .form-grid select, .form-inline input[type="file"], .form-inline select {
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text);
}
.form-grid button { grid-column: 1 / -1; justify-self: start; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid-2, .form-grid { grid-template-columns: 1fr; } }
