:root {
  color-scheme: light;
  --paper: #fff;
  --canvas: #edf0f5;
  --navy: #172641;
  --muted: #525f74;
  --line: #d9dfe9;
  --blue: #2448a8;
  --selection: #e8edf9;
  font: 16px/1.55 "Leelawadee UI", "Thonburi", system-ui, sans-serif;
  color: var(--navy);
  background: var(--canvas);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  background: var(--paper);
  color: var(--navy);
}
button:disabled { cursor: wait; opacity: .65; }
.primary { background: var(--blue); color: white; border-color: var(--blue); white-space: nowrap; }
.primary:hover:not(:disabled) { background: #1b3987; }
:focus-visible { outline: 3px solid #597ae1; outline-offset: 2px; }

.top {
  min-height: 68px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px max(24px, calc((100vw - 1232px) / 2));
  background: var(--navy);
  color: #fff;
}
.identity { display: flex; gap: 11px; align-items: center; font-size: 1.1rem; font-weight: 700; white-space: nowrap; }
.book { width: 17px; height: 21px; border: 2px solid #b3c6ff; border-left-width: 5px; border-radius: 3px; }
.environment { font-size: .87rem; text-align: right; color: #e1e9fc; }
.environment span { display: inline-block; width: 7px; height: 7px; background: #a6beff; border-radius: 50%; margin-right: 5px; }

.layout {
  display: grid;
  grid-template-columns: minmax(290px, 342px) minmax(0, 1fr);
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px;
  gap: 24px;
  align-items: start;
}
aside, .workspace { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
aside { padding: 22px 18px 16px; }
.workspace { padding: 26px 30px 30px; }
.list-header, .editor-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
h1, h2, h3 { margin: 0; line-height: 1.35; }
h1 { font-size: 1.23rem; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1rem; margin-bottom: 10px; }
.filter { margin: 22px 0 13px; }
label { display: grid; gap: 6px; font-size: .9rem; font-weight: 650; }
input, textarea {
  width: 100%;
  min-width: 0;
  background: #fff;
  color: var(--navy);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
input::placeholder, textarea::placeholder { color: #606d80; }
textarea { resize: vertical; min-height: 9rem; }
.notes { display: grid; gap: 5px; }
.note {
  width: 100%;
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 12px 13px;
  border-color: transparent;
  border-left-width: 3px;
  overflow-wrap: anywhere;
}
.note:hover { background: #f3f6fb; }
.note[aria-current="true"] { background: var(--selection); border-left-color: var(--blue); }
.note strong { font-weight: 700; }
.quiet, .note small, .status { color: var(--muted); font-size: .86rem; }
.status { margin: 7px 0 20px; min-height: 1.4em; }
.status[data-level="error"] { color: #972d27; }
.status[data-level="saved"] { color: #125b46; }
fieldset { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 15px; padding: 0; margin: 0; border: 0; min-width: 0; }
.wide { grid-column: 1 / -1; }
.audio { margin-top: 23px; border-top: 1px solid var(--line); padding-top: 18px; }
.audio audio { width: min(100%, 420px); }
#upload { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; max-width: 490px; }
#upload label { grid-column: 1 / -1; color: var(--muted); }
.conflict { margin-bottom: 18px; padding: 12px 15px; border-radius: 8px; background: #fff3db; }
.conflict p { margin: 0 0 8px; }
.conflict pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }
.conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.welcome { padding: 28px 0; color: var(--muted); }
.auth-panel { max-width: 425px; margin: 28px auto; }
.auth-panel form { display: grid; gap: 12px; }
.auth-panel p { margin: 0; color: var(--muted); }
.task-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 6px; margin-bottom: 8px; }
.task-row input[type="date"] { grid-column: 2; max-width: 165px; }
.task-row input[type="checkbox"] { width: 20px; height: 20px; }
#pending-panel { margin-top: 18px; }
#pending-tasks { list-style: none; padding-left: 0; }
#pending-tasks button { margin-bottom: 5px; text-align: left; width: 100%; }
#clip-picker { max-width: 270px; margin-bottom: 8px; }
#upload { margin-top: 8px; }

@media (max-width: 740px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px 12px; gap: 12px; }
  .top { padding-inline: 15px; }
  aside, .workspace { padding: 16px; }
  .notes { max-height: 180px; overflow: auto; }
  h2 { font-size: 1.22rem; }
  fieldset { grid-template-columns: minmax(0, 1fr); }
}
