/* Notepad – warm autumn theme, built from the background colour #f8dcb4 */
:root {
  /* Base: the page background and lighter/darker steps of the same warm sand hue */
  --bg: #f8dcb4;          /* page background */
  --bg-deep: #f1cb97;     /* full-screen popups, hover on the background */
  --surface: #fdf1df;     /* boxes */
  --surface-head: #f9e3c4;/* box header lines, toolbar */
  --paper: #fffaf2;       /* writing area, inputs */
  --hover: #fbe8cc;       /* list row hover */
  --line: #e7c38f;        /* thin frames and dividers */
  --line-strong: #d4a66b; /* input and button frames */
  /* Text: deep browns of the same hue */
  --ink: #3d2410;
  --muted: #7d5735;
  /* Accents: autumn rust and amber that sit next to the sand */
  --accent: #b4521a;
  --accent-dark: #8f3e12;
  --accent-soft: #f5d0b0;
  --gold: #c98b2b;
  --gold-soft: #f3dcae;
  /* Top bar and popup headers: dark chestnut */
  --bar: #5c3214;
  --bar-text: #fdebd0;
  --bar-line: rgba(253, 235, 208, .4);
  /* States */
  --danger: #a3261b;
  --danger-dark: #7d1d12;
  --danger-soft: #f7d4cc;
  --ok: #3d6b25;
  --warn: #8a5a00;
  --shadow: 0 3px 12px rgba(120, 70, 25, .16);
  --shadow-big: 0 12px 40px rgba(60, 30, 10, .35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font: 16px/1.5 "Segoe UI", Tahoma, Verdana, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
body.noscroll { overflow: hidden; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bar); color: var(--bar-text);
  border-bottom: 3px solid var(--gold);
  padding-top: env(safe-area-inset-top, 0px);
  box-shadow: 0 2px 8px rgba(60, 30, 10, .25);
}
.topbar-in {
  max-width: 960px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.brand { font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; font-weight: bold; letter-spacing: .5px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline { display: inline; margin: 0; }
.status { font-size: .85rem; color: var(--bar-text); opacity: .85; }
.status.bad { color: #ffc2b3; opacity: 1; font-weight: 600; }

.wrap { max-width: 960px; margin: 0 auto; padding: 20px 16px 48px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block; font: inherit; font-size: .95rem; line-height: 1.2;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--paper); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent-dark); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: var(--danger); border-color: #dda89b; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger-dark); color: #fff; }
.btn-danger-solid:hover { background: var(--danger-dark); }
.btn-small { padding: 6px 12px; font-size: .88rem; }
.btn-bar { background: transparent; color: var(--bar-text); border-color: var(--bar-line); }
.btn-bar:hover { background: rgba(253, 235, 208, .15); }
.btn-icon { padding: 7px 12px; font-size: 1.05rem; line-height: 1; }
.btn-block { display: block; width: 100%; padding: 11px; }
.btn[disabled] { opacity: .6; cursor: default; }

/* ---------- clock ---------- */
.clock {
  display: inline-flex; align-items: center; gap: 14px;
  margin: 4px 0 20px; padding: 10px 18px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow);
}
.clock-time {
  font-family: Georgia, "Times New Roman", serif; font-size: 2.6rem; font-weight: bold; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: 1px;
  padding-right: 14px; border-right: 1px solid var(--line);
}
.clock-side { line-height: 1.3; }
.clock-day { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 2px; color: var(--accent); }
.clock-date { font-family: Georgia, "Times New Roman", serif; font-size: 1.1rem; }
.clock-tz { font-size: .72rem; color: var(--muted); }

/* ---------- cards and document lists ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 12px 18px; background: var(--surface-head); border-bottom: 1px solid var(--line);
}
.card-head h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.25rem; }
.card-body { padding: 20px; }
.empty { margin: 0; padding: 22px 18px; color: var(--muted); }

.doclist { list-style: none; margin: 0; padding: 0; }
.doc {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--line);
}
.doc:last-child { border-bottom: 0; }
.doc:hover { background: var(--hover); }
.doc-info { flex: 1; min-width: 0; }
.doc-title { font-weight: 600; font-size: 1.05rem; color: var(--ink); text-decoration: none; word-break: break-word; }
.doc-title:hover { color: var(--accent); text-decoration: underline; }
.doc-stamps { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.doc-stamps span + span::before { content: " \00b7  "; }
.doc-actions { display: flex; gap: 6px; flex-shrink: 0; }
/* In the full list (More) the buttons sit under the document, to the left */
.doc-full { flex-direction: column; align-items: stretch; gap: 8px; }
.doc-full .doc-actions { justify-content: flex-start; }

.badge {
  display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 10px; vertical-align: 2px;
  font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  background: var(--gold-soft); color: #75491c;
}
.badge-formatted { background: var(--accent-soft); color: var(--accent-dark); }
.badge-locked { background: var(--bar); color: var(--bar-text); }
.doc-info .badge + .badge { margin-left: 4px; }
.btn-locked { background: var(--bar); border-color: var(--bar); color: var(--bar-text); }
.btn-locked:hover { background: #47260f; }
.btn-locked[disabled] { opacity: 1; }

/* ---------- forms ---------- */
.login { max-width: 400px; margin: 6vh auto 0; }
.form label { display: block; margin-bottom: 14px; font-weight: 600; font-size: .92rem; }
.form small { font-weight: normal; color: var(--muted); }
.form input, .form select {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px;
  font: inherit; font-weight: normal; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: 8px;
}
.form input:focus, .form select:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.form input.input-short { max-width: 120px; }
.form label.check { display: flex; align-items: center; gap: 8px; font-weight: normal; }
.form label.check input { display: inline-block; width: 18px; height: 18px; margin: 0; flex-shrink: 0; }
.devlist { list-style: none; margin: 0 0 14px; padding: 0; border: 1px solid var(--line); border-radius: 8px; }
.dev { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 12px; }
.dev + .dev { border-top: 1px solid var(--line); }
.dev-info { flex: 1; min-width: 0; }
.dev .badge { vertical-align: 1px; }
.error { background: var(--danger-soft); color: var(--danger-dark); padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; }
.msg { margin: 10px 0 0; }
.msg:empty { display: none; }
.msg.ok { color: var(--ok); }
.msg.bad { color: var(--danger); }
.msg.warn { color: var(--warn); }
.hint { color: var(--muted); margin: 0 0 10px; font-size: .92rem; }

/* ---------- popups ---------- */
.modal {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(61, 36, 16, .55);
}
.modal-box {
  display: flex; flex-direction: column; width: 100%; max-width: 480px; max-height: 100%;
  background: var(--surface); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-big);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px; background: var(--bar); color: var(--bar-text); border-bottom: 3px solid var(--gold);
}
.modal-head h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.2rem; }
.modal-body { flex: 1; overflow: auto; padding: 18px; -webkit-overflow-scrolling: touch; }
.modal-body p:first-child { margin-top: 0; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
  padding: 12px 18px; border-top: 1px solid var(--line);
}
.modal.full { padding: 0; }
.modal.full .modal-box { max-width: none; height: 100%; border-radius: 0; }
.modal.full .modal-head { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
.modal.full .modal-body { background: var(--bg); padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
.modal-in { max-width: 900px; margin: 0 auto; }

.choice {
  display: block; margin-bottom: 12px; padding: 14px 16px;
  background: var(--paper); border: 2px solid var(--line); border-radius: 10px;
  color: var(--ink); text-decoration: none;
}
.choice:hover, .choice:focus { border-color: var(--accent); background: #fff; }
.choice strong { display: block; font-size: 1.1rem; margin-bottom: 2px; }
.choice span { font-size: .9rem; color: var(--muted); }

.setup-sec {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; margin-bottom: 18px;
}
details.setup-sec > summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; }
details.setup-sec > summary::-webkit-details-marker { display: none; }
details.setup-sec > summary h3 { margin: 0; }
details.setup-sec > summary::after {
  content: ""; width: 8px; height: 8px; margin-left: auto;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform .15s;
}
details.setup-sec[open] > summary { margin-bottom: 12px; }
details.setup-sec[open] > summary::after { transform: rotate(-135deg); }
details.setup-sec > summary:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; border-radius: 4px; }
.setup-sec h3 { margin: 0 0 12px; font-family: Georgia, "Times New Roman", serif; font-size: 1.15rem; }
.kv { width: 100%; border-collapse: collapse; font-size: .92rem; margin-bottom: 6px; }
.kv th { width: 42%; padding: 7px 10px 7px 0; text-align: left; vertical-align: top; font-weight: 600; color: var(--muted); }
.kv th small { font-weight: normal; }
.kv td { padding: 7px 0; font-variant-numeric: tabular-nums; }
.kv tr + tr { border-top: 1px dashed var(--line); }

/* ---------- editor and viewer ---------- */
.doc-type {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-bottom: 12px; padding: 8px 12px; font-size: .9rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
.doc-type .badge { margin: 0 4px 0 0; vertical-align: 0; }
.locked { color: var(--muted); }

.title-input {
  display: block; width: 100%; padding: 10px 14px;
  font: bold 1.4rem Georgia, "Times New Roman", serif; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
}
.title-input:focus { outline: 3px solid var(--gold); }
.view-title {
  margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.8rem;
  color: var(--ink); word-break: break-word;
}
.stamps { font-size: .82rem; color: var(--muted); margin: 6px 2px 12px; }
.stamps span + span::before { content: " \00b7  "; }

.toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px;
  background: var(--surface-head); border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0;
}
.toolbar + .paper { border-radius: 0 0 10px 10px; }
.toolbar select {
  font: inherit; font-size: .95rem; padding: 7px 8px; height: 38px;
  color: var(--ink); background: var(--paper); border: 1px solid var(--line-strong); border-radius: 8px;
}
.tool { min-width: 42px; height: 38px; padding: 0 10px; font-size: 1.05rem; font-family: Georgia, "Times New Roman", serif; }
.tool.active { background: var(--accent); border-color: var(--accent-dark); color: #fff; }

.paper {
  display: block; width: 100%; min-height: 60vh; margin: 0; padding: 18px 22px;
  font-family: Georgia, "Times New Roman", serif; font-size: 18px; line-height: 1.65; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow);
  overflow-wrap: break-word; word-wrap: break-word;
}
.paper:focus { outline: 3px solid var(--gold); outline-offset: 0; }
textarea.paper { resize: vertical; }
.plain-view { white-space: pre-wrap; }
.rich:empty::before { content: attr(data-placeholder); color: #b39371; }
/* Font sizes from the formatted editor, relative to the normal text size */
.rich font[size="1"] { font-size: .65em; }
.rich font[size="2"] { font-size: .8em; }
.rich font[size="3"] { font-size: 1em; }
.rich font[size="4"] { font-size: 1.2em; }
.rich font[size="5"] { font-size: 1.5em; }
.rich font[size="6"] { font-size: 2em; }
.rich font[size="7"] { font-size: 2.6em; }

/* ---------- phones ---------- */
@media (max-width: 560px) {
  .wrap { padding-top: 14px; }
  .clock { gap: 12px; padding: 8px 14px; }
  .clock-time { font-size: 2.1rem; padding-right: 12px; }
  .clock-date { font-size: 1rem; }
  .doc-stamps span, .stamps span { display: block; }
  .doc-stamps span + span::before, .stamps span + span::before { content: none; }
  .paper { font-size: 17px; padding: 14px 15px; min-height: 55vh; }
  .title-input { font-size: 1.2rem; }
  .modal-foot .btn { flex: 1; }
}
