/* style.css */
:root {
  color-scheme: light;
  --custom-page: #f4eee3;
  --custom-accent: #b36e4f;
  --bg: var(--custom-page);
  --bg-deep: #ebe1d1;
  --paper: #fffdf8;
  --paper-soft: #f8f1e6;
  --paper-hover: #f2e9db;
  --border: #ded2c1;
  --border-strong: #cbbba5;
  --text: #3e372f;
  --muted: #8b7d6b;
  --accent: var(--custom-accent);
  --accent-dark: #8e5037;
  --accent-soft: #f1dfd2;
  --danger: #aa554d;
  --shadow: 0 18px 50px rgba(92, 67, 42, .08);
}

body.dark {
  color-scheme: dark;
  --bg-deep: #20221f;
  --paper: #232522;
  --paper-soft: #292c28;
  --paper-hover: #30332e;
  --border: #3b4038;
  --border-strong: #555b50;
  --text: #eee9df;
  --muted: #a39d91;
  --accent-dark: #efab85;
  --accent-soft: #49352c;
  --danger: #ee9588;
  --shadow: 0 18px 50px rgba(0, 0, 0, .22);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 27rem),
    var(--bg);
  font-family: Georgia, "Times New Roman", serif;
  transition: background .25s ease, color .25s ease;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 3px;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 52px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -.02em;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  color: #fffaf2;
  background: var(--accent);
  font-size: .95rem;
  font-weight: 700;
}

.top-actions {
  display: flex;
  gap: 9px;
}

.button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: var(--paper);
  font-family: system-ui, sans-serif;
  font-size: .82rem;
  font-weight: 700;
  transition: .18s ease;
}

.button:hover,
.layout-button:hover,
.preset-button:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.button.primary {
  border-color: var(--accent);
  color: #fffaf2;
  background: var(--accent);
}

.button.primary:hover {
  background: var(--accent-dark);
}

.button.subtle {
  background: transparent;
}

.customizer {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.customizer-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.customizer h2,
.thought-heading h2 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -.035em;
}

.close-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
}

.customizer-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: end;
  gap: 20px;
}

.control-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-family: system-ui, sans-serif;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.preset-row,
.layout-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-button,
.layout-button {
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  background: var(--paper-soft);
  font-family: system-ui, sans-serif;
  font-size: .75rem;
  font-weight: 700;
  transition: .18s ease;
}

.preset-button::before {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 7px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.preset-paper { color: #b36e4f; }
.preset-night { color: #8d9b92; }
.preset-moss { color: #66856a; }
.preset-lilac { color: #836d9d; }

.color-control input {
  display: block;
  width: 64px;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--paper-soft);
  cursor: pointer;
}

.layout-controls {
  margin-top: 20px;
  padding-top: 17px;
  border-top: 1px solid var(--border);
}

.layout-button.active {
  border-color: var(--accent);
  color: #fffaf2;
  background: var(--accent);
}

.workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 640px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

body[data-layout="triple"] .workspace {
  grid-template-columns: 230px minmax(0, 1fr) minmax(230px, 300px);
}

body[data-layout="horizontal"] .workspace {
  grid-template-columns: 260px minmax(0, 1fr);
}

.notes-panel {
  padding: 22px 16px;
  border-right: 1px solid var(--border);
  background: var(--paper-soft);
}

.panel-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 0 6px 18px;
}

.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
  font-family: system-ui, sans-serif;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -.04em;
}

.note-count,
.bubble-count,
#bubbleCount {
  color: var(--muted);
  font-family: system-ui, sans-serif;
  font-size: .78rem;
}

.search-wrap {
  display: block;
  margin-bottom: 15px;
  padding: 0 6px;
  color: var(--muted);
  font-family: system-ui, sans-serif;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.search-wrap input {
  width: 100%;
  min-height: 40px;
  margin-top: 7px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  background: var(--paper);
  font-size: .82rem;
  text-transform: none;
  letter-spacing: normal;
}

.note-list {
  display: grid;
  gap: 5px;
}

.note-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  text-align: left;
  transition: .18s ease;
}

.note-item:hover {
  background: var(--paper-hover);
}

.note-item.selected {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: var(--accent-soft);
}

.note-item strong,
.note-item span,
.note-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-item strong {
  font-size: .9rem;
}

.note-item span {
  color: var(--muted);
  font-size: .78rem;
}

.note-item small {
  color: var(--muted);
  font-family: system-ui, sans-serif;
  font-size: .65rem;
}

.list-empty,
.bubble-empty {
  margin: 15px 6px;
  color: var(--muted);
  font-size: .85rem;
}

.new-note-link {
  width: 100%;
  margin-top: 14px;
  padding: 11px 8px;
  border: 0;
  border-top: 1px solid var(--border);
  color: var(--accent-dark);
  background: transparent;
  text-align: left;
  font-family: system-ui, sans-serif;
  font-size: .78rem;
  font-weight: 700;
}

.writing-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: clamp(24px, 5vw, 66px) clamp(22px, 7vw, 100px);
  background: var(--paper);
}

body[data-layout="horizontal"] .writing-panel {
  min-height: 500px;
}

.writing-header {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.note-title {
  width: 100%;
  padding: 0;
  border: 0;
  color: var(--text);
  outline: 0;
  background: transparent;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  font-weight: 700;
  letter-spacing: -.045em;
}

.note-title::placeholder {
  color: var(--muted);
  opacity: .65;
}

.writing-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
  color: var(--muted);
  font-family: system-ui, sans-serif;
  font-size: .72rem;
}

.meta-divider {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--border-strong);
}

#noteBody {
  flex: 1;
  width: 100%;
  min-height: 430px;
  padding: 30px 0;
  border: 0;
  outline: 0;
  resize: none;
  color: var(--text);
  background: transparent;
  font-size: clamp(1.05rem, 1.8vw, 1.22rem);
  line-height: 1.85;
}

#noteBody::placeholder {
  color: var(--muted);
  opacity: .6;
}

.writing-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding-top: 17px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-family: system-ui, sans-serif;
  font-size: .7rem;
}

.footer-actions {
  display: flex;
  gap: 13px;
}

.text-button {
  min-height: 30px;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-family: system-ui, sans-serif;
  font-size: .72rem;
  font-weight: 700;
}

.text-button:hover {
  color: var(--accent-dark);
}

.text-button.danger:hover {
  color: var(--danger);
}

.thought-panel {
  display: none;
  min-width: 0;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--paper-soft);
}

body[data-layout="triple"] .thought-panel {
  display: flex;
}

.scenery {
  position: relative;
  height: 112px;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 12%, var(--paper)) 0%, var(--paper-soft) 100%);
}

.sun {
  position: absolute;
  top: 22px;
  right: 25px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 65%, #f4c978);
  opacity: .8;
}

.hill {
  position: absolute;
  bottom: -38px;
  width: 75%;
  height: 90px;
  border-radius: 50% 50% 0 0;
  background: color-mix(in srgb, var(--accent) 28%, var(--paper-soft));
}

.hill-one {
  left: -20px;
}

.hill-two {
  right: -30px;
  bottom: -48px;
  background: color-mix(in srgb, var(--accent) 17%, var(--paper-soft));
}

.thought-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  padding: 21px 18px 15px;
}

.bubble-list {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 0 15px 22px;
  overflow: auto;
}

.thought-bubble {
  position: relative;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  border-radius: 17px 17px 17px 5px;
  color: var(--text);
  background: var(--paper);
  font-size: .86rem;
  line-height: 1.5;
  animation: bubble-in .3s both;
  animation-delay: var(--bubble-delay);
}

.thought-bubble:nth-child(even) {
  border-radius: 17px 17px 5px 17px;
  background: var(--accent-soft);
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  padding: 16px 3px 0;
  color: var(--muted);
  font-family: system-ui, sans-serif;
  font-size: .7rem;
}

.footer-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.shortcut-hint {
  display: flex;
  align-items: center;
  gap: 4px;
}

kbd {
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--paper);
  font-size: .62rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 5;
  padding: 10px 15px;
  border-radius: 999px;
  color: var(--bg);
  background: var(--text);
  font-family: system-ui, sans-serif;
  font-size: .78rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 15px);
  transition: .2s ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 900px) {
  body[data-layout="triple"] .workspace {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  body[data-layout="triple"] .thought-panel {
    grid-column: 1 / -1;
    min-height: 260px;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  body[data-layout="triple"] .bubble-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .app-shell {
    padding: 14px 10px 22px;
  }

  .topbar {
    align-items: flex-start;
    margin-bottom: 18px;
  }

  .top-actions {
    flex-direction: column;
  }

  .top-actions .button {
    min-height: 40px;
    padding: 0 12px;
  }

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

  .customizer-grid > div {
    grid-column: 1 / -1;
  }

  .workspace,
  body[data-layout="triple"] .workspace {
    display: flex;
    min-height: 0;
    flex-direction: column;
  }

  .notes-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .note-list {
    max-height: 190px;
    overflow-y: auto;
  }

  .writing-panel {
    min-height: 620px;
    padding: 30px 22px;
  }

  #noteBody {
    min-height: 390px;
  }

  .thought-panel,
  body[data-layout="triple"] .thought-panel {
    display: flex;
    min-height: 300px;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  body[data-layout="triple"] .bubble-list {
    grid-template-columns: 1fr;
  }

  .writing-footer,
  .app-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .shortcut-hint {
    display: none;
  }
}

@media (max-width: 420px) {
  .brand {
    font-size: .95rem;
  }

  .top-actions {
    gap: 5px;
  }

  .top-actions .button {
    font-size: .7rem;
  }

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

  .writing-panel {
    padding: 25px 17px;
  }

  .note-title {
    font-size: 1.85rem;
  }
}
