:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --paper: #ffffff;
  --ink: #252428;
  --muted: #686a70;
  --line: #dedfe3;
  --green: #2e7d6f;
  --green-dark: #1f5f54;
  --coral: #c96356;
  --violet: #615a99;
  --shadow: 0 18px 40px rgba(37, 36, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  min-height: 40px;
  padding: 0 16px;
  color: #fff;
  background: var(--green);
}

button:hover {
  background: var(--green-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--paper);
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46, 125, 111, 0.14);
}

input {
  min-height: 40px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  line-height: 1.65;
  padding: 16px;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 56px;
}

.top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.mark {
  margin: 0 0 8px;
  color: var(--coral);
  font-size: 0.9rem;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 6vw, 4.6rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
  letter-spacing: 0;
}

h3 {
  font-size: 0.95rem;
  letter-spacing: 0;
}

.search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.composer {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px;
}

.composer textarea {
  border: 0;
  min-height: 190px;
  padding: 12px;
  box-shadow: none;
}

.composer textarea:focus {
  box-shadow: none;
}

.composerFoot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.optionalFields summary {
  width: max-content;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.92rem;
}

.fieldGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.dropButton {
  min-width: 92px;
  background: var(--ink);
}

.dropButton:hover {
  background: #000;
}

.recent {
  margin-top: 28px;
}

.sectionHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.sectionHead h2 {
  margin-bottom: 0;
}

.ghostButton {
  border: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
}

.ghostButton:hover {
  border-color: var(--green);
  color: var(--green-dark);
  background: rgba(46, 125, 111, 0.08);
}

.noteList {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.noteCard {
  display: grid;
  min-height: 172px;
  align-content: start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  text-align: left;
  color: var(--ink);
  background: var(--paper);
}

.noteCard:hover {
  border-color: rgba(46, 125, 111, 0.5);
  background: #fbfdfc;
}

.noteCard h3 {
  margin: 0;
  overflow-wrap: anywhere;
}

.noteTime,
.readerMeta,
.empty,
.tags {
  color: var(--muted);
  font-size: 0.86rem;
}

.preview {
  margin: 0;
  color: #44464c;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  border: 1px solid rgba(97, 90, 153, 0.25);
  border-radius: 8px;
  padding: 2px 7px;
  color: var(--violet);
  background: rgba(97, 90, 153, 0.06);
}

.empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px 18px;
  text-align: center;
  background: rgba(255, 255, 255, 0.55);
}

.reader {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  justify-items: end;
  background: rgba(37, 36, 40, 0.28);
}

.keyGate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(37, 36, 40, 0.28);
  padding: 18px;
}

.keyGate[hidden] {
  display: none;
}

.keyPanel {
  display: grid;
  width: min(360px, 100%);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 18px;
}

.keyPanel label {
  color: var(--muted);
  font-size: 0.92rem;
}

.reader[hidden] {
  display: none;
}

.readerPanel {
  position: relative;
  width: min(720px, 100%);
  height: 100%;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--paper);
  box-shadow: -22px 0 50px rgba(37, 36, 40, 0.14);
  padding: 34px;
}

.closeButton {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  min-height: 38px;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  font-size: 1.5rem;
  line-height: 1;
}

.closeButton:hover {
  color: var(--coral);
  border-color: rgba(201, 99, 86, 0.45);
  background: rgba(201, 99, 86, 0.08);
}

#readerTitle {
  margin: 18px 48px 16px 0;
  font-size: 1.7rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

#readerContent {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: inherit;
  line-height: 1.72;
}

.reflectionBlock {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  padding-top: 18px;
}

.reflectionItem {
  border-left: 3px solid rgba(46, 125, 111, 0.42);
  margin: 0 0 14px;
  padding-left: 12px;
}

.reflectionItem time {
  color: var(--muted);
  font-size: 0.84rem;
}

.reflectionItem p {
  margin: 6px 0 0;
  line-height: 1.62;
  white-space: pre-wrap;
}

#reflectionInput {
  min-height: 112px;
}

.readerActions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
}

@media (max-width: 840px) {
  .top,
  .composerFoot {
    grid-template-columns: 1fr;
  }

  .fieldGrid,
  .noteList {
    grid-template-columns: 1fr;
  }

  .dropButton {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1120px);
    padding-top: 20px;
  }

  .search {
    grid-template-columns: 1fr;
  }

  .readerPanel {
    padding: 26px 18px;
  }

  #readerTitle {
    font-size: 1.35rem;
  }

  .readerActions {
    display: grid;
  }
}
