:root {
  --bg: #fffaf2;
  --paper: #ffffff;
  --ink: #19140f;
  --muted: #73675f;
  --line: #eadfce;
  --accent: #8f4c16;
  --accent-2: #f2d19b;
  --danger: #b42318;
  --ok: #0f7a45;
  --shadow: 0 18px 55px rgba(48, 30, 12, .12);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Noto Sans Malayalam', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: radial-gradient(circle at top left, #ffe8bd 0, transparent 35%), var(--bg);
  color: var(--ink);
  line-height: 1.7;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 14px clamp(16px, 4vw, 52px);
  background: rgba(255,250,242,.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; background: linear-gradient(145deg, var(--accent), #3d1f0b); box-shadow: var(--shadow);
}
nav { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
nav a, .btn, button, input[type=file]::file-selector-button {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font-family: inherit;
  font-weight: 700;
  background: #fff;
  border: 1px solid var(--line);
  cursor: pointer;
}
.pill, .btn.primary, button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.ghost { background: transparent; }
.container { width: min(1120px, calc(100% - 28px)); margin: 30px auto 70px; }
.hero {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 28px;
  align-items: center;
}
.card, .panel, .editor-card {
  background: rgba(255,255,255,.88);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.card { padding: clamp(22px, 4vw, 44px); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 12px; }
h1 { font-size: clamp(32px, 6vw, 64px); letter-spacing: -.04em; }
h2 { font-size: clamp(24px, 4vw, 38px); }
h3 { font-size: 22px; }
.lead { font-size: clamp(17px, 2vw, 21px); color: var(--muted); }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.panel { padding: 22px; }
.muted { color: var(--muted); }
.alert { padding: 14px 16px; border-radius: 18px; margin-bottom: 18px; border: 1px solid var(--line); background: #fff; }
.alert.ok { color: var(--ok); border-color: rgba(15,122,69,.25); }
.alert.bad { color: var(--danger); border-color: rgba(180,35,24,.25); }
form { display: grid; gap: 14px; }
label { font-weight: 800; }
input, textarea, select {
  width: 100%; padding: 13px 14px; border-radius: 16px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-family: inherit; font-size: 16px;
}
textarea { min-height: 140px; resize: vertical; }
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; }
.checkbox input { width: auto; margin-top: 8px; }
.novel-list { display: grid; gap: 14px; }
.novel-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 16px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 22px; background: #fff; }
.cover { width: 92px; height: 120px; border-radius: 16px; object-fit: cover; background: #f2e5d4; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 13px; }
.chapter-row { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.editor-shell { display: grid; grid-template-columns: 280px 1fr; gap: 18px; align-items: start; }
.editor-side { position: sticky; top: 86px; }
.editor-card { padding: 16px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px; border-bottom: 1px solid var(--line); background: #fff7eb; border-radius: 24px 24px 0 0; }
.toolbar button { border-radius: 14px; padding: 8px 12px; background: #fff; }
.writer {
  min-height: 62vh;
  padding: clamp(18px, 4vw, 44px);
  outline: none;
  font-size: clamp(17px, 2vw, 20px);
  background: #fff;
  border-radius: 0 0 24px 24px;
}
.writer:empty:before { content: attr(data-placeholder); color: #a49587; }
.writer p { margin: 0 0 1.1em; }
.writer img, .reading img { display: block; margin: 22px auto; border-radius: 22px; box-shadow: var(--shadow); }
.reading { max-width: 780px; margin: 0 auto; font-size: clamp(18px, 2vw, 21px); }
.meta-bar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.searchbar { display: flex; gap: 10px; margin: 20px 0; }
.searchbar input { flex: 1; }
.status { display: inline-block; border-radius: 999px; padding: 4px 10px; background: #f7ead6; color: #74410f; font-size: 13px; font-weight: 800; }
.footer { text-align: center; color: var(--muted); padding: 28px 14px 50px; }

@media (max-width: 860px) {
  .hero, .two, .editor-shell { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .editor-side { position: static; }
  .novel-row { grid-template-columns: 76px 1fr; }
  .novel-row .actions { grid-column: 1 / -1; }
  .cover { width: 76px; height: 100px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  nav { justify-content: flex-start; }
}
@media (max-width: 520px) {
  .container { width: min(100% - 18px, 1120px); margin-top: 18px; }
  nav a, .btn, button { padding: 9px 12px; font-size: 14px; }
  .card, .panel { border-radius: 22px; }
  .searchbar { flex-direction: column; }
  .chapter-row { grid-template-columns: 1fr; }
}
