/* Diary — calm, deep, low-blue dark theme */

:root {
  --bg: #0a0805;
  --bg-2: #100c08;
  --surface: rgba(34, 27, 21, 0.62);
  --surface-solid: #181310;
  --surface-2: rgba(46, 36, 28, 0.70);
  --surface-2-solid: #221a14;
  --surface-3: #2a2018;
  --text: #d8c8ac;
  --text-soft: #c2b298;
  --muted: #998a73;
  --muted-2: #6b5e4e;
  --accent: #b9926b;
  --accent-2: #8d6c4d;
  --accent-soft: #d4b594;
  --accent-glow: rgba(185, 146, 107, 0.18);
  --accent-grad: linear-gradient(135deg, #8d6c4d 0%, #b9926b 60%, #d4b594 100%);
  --danger: #c47a5e;
  --border: rgba(185, 146, 107, 0.14);
  --border-soft: rgba(185, 146, 107, 0.07);
  --radius: 16px;
  --radius-lg: 22px;
  --shadow-card: 0 1px 0 rgba(255, 220, 180, 0.025) inset, 0 8px 24px rgba(0, 0, 0, 0.42);
  --shadow-glow: 0 0 0 1px var(--border), 0 14px 40px rgba(0, 0, 0, 0.5);
  --shadow-deep: 0 28px 70px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--border);

  --font-display: "Manrope", "Inter", -apple-system, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background:
    radial-gradient(1500px 900px at 18% -20%, rgba(185, 146, 107, 0.09) 0%, transparent 70%),
    radial-gradient(900px 700px at 95% 110%, rgba(141, 108, 77, 0.06) 0%, transparent 65%),
    var(--bg);
  background-attachment: fixed;
}

a { color: var(--accent-soft); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 32px;
  background: rgba(10, 8, 5, 0.78);
  backdrop-filter: blur(24px) saturate(120%);
  -webkit-backdrop-filter: blur(24px) saturate(120%);
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--accent-soft);
  position: relative;
  padding-right: 18px;
}
.brand::after {
  content: "";
  position: absolute;
  right: 0; top: 18%;
  height: 64%;
  width: 1px;
  background: var(--border);
}

.motto {
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--muted);
  letter-spacing: 0.1px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tabs {
  display: flex;
  gap: 2px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
}

.tab {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 7px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.2px;
  transition: color 0.2s, background 0.2s;
  font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: rgba(185, 146, 107, 0.13);
  color: var(--accent-soft);
}

.datepick {
  display: flex;
  align-items: center;
  gap: 6px;
}

input[type=date] {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
  font-family: inherit;
  color-scheme: dark;
  backdrop-filter: blur(10px);
}

input[type=text] {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
}

input[type=text]:focus,
input[type=date]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(185, 146, 107, 0.10);
}

button { font-family: inherit; }

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: all 0.2s;
  backdrop-filter: blur(10px);
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.ghost-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.2px;
  backdrop-filter: blur(10px);
  transition: all 0.2s;
}
.ghost-btn:hover {
  background: var(--surface-2);
  color: var(--accent-soft);
}

.primary-btn {
  background: var(--accent);
  border: 0;
  color: #1a1410;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 230, 200, 0.12) inset;
  transition: background 0.2s, transform 0.1s;
  font-family: inherit;
}
.primary-btn:hover { background: var(--accent-soft); }
.primary-btn:active { transform: translateY(1px); }

.danger-btn {
  background: transparent;
  border: 1px solid rgba(196, 122, 94, 0.28);
  color: var(--danger);
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  font-family: inherit;
}
.danger-btn:hover { background: rgba(196, 122, 94, 0.10); border-color: var(--danger); }

main {
  padding: 44px 32px 100px;
  max-width: 1200px;
  margin: 0 auto;
}

.view { display: none; }
.view.active { display: block; }

.view-header {
  margin-bottom: 32px;
}
.view-header h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 30px;
  margin: 0 0 8px;
  letter-spacing: -0.6px;
  color: var(--text);
}
.view-header .view-sub {
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Daily cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.card {
  position: relative;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 24px 24px 22px;
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s, transform 0.25s;
  display: flex;
  flex-direction: column;
  min-height: 188px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.card:hover {
  border-color: var(--border);
  background: var(--surface-2);
  transform: translateY(-1px);
}

.card.filled {
  background: linear-gradient(165deg, rgba(185, 146, 107, 0.07) 0%, var(--surface) 70%);
  border-color: var(--border);
}
.card.filled::after {
  content: "";
  position: absolute;
  left: 0; top: 20px; bottom: 20px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
  opacity: 0.7;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.card-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted-2);
  letter-spacing: 0.6px;
  min-width: 30px;
  background: var(--surface-2);
  padding: 3px 8px;
  border-radius: 6px;
  text-align: center;
}
.card.filled .card-num {
  background: rgba(185, 146, 107, 0.12);
  color: var(--accent-soft);
}
.card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.2px;
  color: var(--text);
  flex: 1;
}
.card.filled .card-title { color: var(--accent-soft); }

.card-preview {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-soft);
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  flex: 1;
}

.card-empty {
  font-size: 13px;
  color: var(--muted-2);
  flex: 1;
  display: flex;
  align-items: center;
}

/* ---------- Modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 4, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal.hidden { display: none; }

.modal-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 840px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-deep);
  overflow: hidden;
  animation: slideUp 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 30px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.modal-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.3px;
}
.modal-head h3 .h-cat {
  color: var(--accent-soft);
}
.modal-head h3 .h-sep { color: var(--muted-2); margin: 0 12px; font-weight: 300; }
.modal-head h3 .h-date {
  font-weight: 400;
  font-size: 14.5px;
  color: var(--muted);
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 30px;
  border-top: 1px solid var(--border-soft);
  background: rgba(34, 27, 21, 0.3);
  min-height: 52px;
}

textarea {
  background: transparent;
  color: var(--text);
  border: 0;
  padding: 28px 32px;
  font-size: 16px;
  line-height: 1.85;
  font-family: var(--font-body);
  resize: none;
  min-height: 320px;
  flex: 1;
  caret-color: var(--accent);
}

#modal-content { min-height: 55vh; }
#modal-content.hidden { display: none; }

.status {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.2px;
}
.status.ok { color: var(--accent-soft); }
.status.err { color: var(--danger); }

/* ---------- Checklist (Tagesnotizen) ---------- */

.checklist {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 28px 14px;
  overflow-y: auto;
  min-height: 55vh;
}
.checklist.hidden { display: none; }

.checklist ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.checklist li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--border-soft);
  transition: opacity 0.15s;
}
.checklist li:last-child { border-bottom: 0; }

.item-check {
  width: 22px;
  height: 22px;
  border: 1.5px solid rgba(185, 146, 107, 0.30);
  border-radius: 7px;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  background: transparent;
  color: transparent;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}
.item-check:hover {
  border-color: var(--accent);
}
.checklist li.done .item-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1410;
}
.checklist li.done .item-check::before { content: "✓"; }

.item-text {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  padding: 6px 0;
  outline: none;
}
.checklist li.done .item-text {
  text-decoration: line-through;
  color: var(--muted-2);
}

.item-del {
  background: transparent;
  border: 0;
  color: var(--muted-2);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  opacity: 0;
  transition: all 0.15s;
}
.checklist li:hover .item-del { opacity: 0.7; }
.item-del:hover { background: rgba(196, 122, 94, 0.10); color: var(--danger); opacity: 1; }

.checklist-add {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 4px 4px;
  margin-top: 6px;
}
.checklist-add-mark {
  width: 22px;
  height: 22px;
  border: 1.5px dashed rgba(185, 146, 107, 0.25);
  border-radius: 7px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-soft);
  font-weight: 600;
  font-size: 13px;
}
#checklist-new {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  padding: 6px 0;
  outline: none;
}
#checklist-new::placeholder { color: var(--muted-2); }

/* Card preview as checklist (Tagesnotizen) */

.prev-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 4px;
}
.prev-check {
  flex-shrink: 0;
  font-size: 11px;
  width: 12px;
  color: var(--muted-2);
}
.prev-item.done {
  text-decoration: line-through;
  color: var(--muted-2);
}
.prev-item.done .prev-check {
  color: var(--accent-soft);
}

/* ---------- Quicknotes ---------- */

.qn-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 22px;
  height: calc(100vh - 230px);
  min-height: 480px;
}

.qn-sidebar {
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.qn-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 6px 16px;
}
.qn-sidebar-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

.qn-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
}

.qn-list li {
  position: relative;
  padding: 13px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
  margin-bottom: 3px;
}
.qn-list li:hover { background: var(--surface-2); }
.qn-list li.active {
  background: rgba(185, 146, 107, 0.10);
}
.qn-list li.active::before {
  content: "";
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
  opacity: 0.7;
}
.qn-list li .qn-name {
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
}
.qn-list li.active .qn-name { color: var(--accent-soft); }
.qn-list li .qn-meta {
  font-size: 11px;
  color: var(--muted-2);
  margin-top: 4px;
  letter-spacing: 0.3px;
  font-family: var(--font-mono);
}
.qn-empty {
  color: var(--muted);
  padding: 16px;
  text-align: center;
  font-size: 13px;
}

.qn-editor {
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.qn-editor-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-soft);
}

#qn-name {
  flex: 1;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  background: transparent;
  border: 0;
  padding: 4px 0;
  color: var(--text);
}
#qn-name:focus { box-shadow: none; }

.qn-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

#qn-content { min-height: 0; flex: 1; padding: 24px 28px; }

/* ---------- Month view ---------- */

#month-title {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: -0.6px;
  color: var(--text);
}
.month-sub {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 26px;
}

.month-grid {
  display: grid;
  grid-template-columns: 140px repeat(31, minmax(20px, 1fr));
  gap: 4px;
  overflow-x: auto;
  font-size: 11px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-card);
}

.mg-header,
.mg-row-label {
  background: transparent;
  padding: 6px 4px;
  color: var(--muted-2);
  font-size: 11px;
  text-align: center;
  letter-spacing: 0.4px;
  font-family: var(--font-mono);
}
.mg-row-label {
  text-align: left;
  padding-left: 10px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.1px;
}
.mg-header { font-weight: 500; }

.mg-cell {
  height: 28px;
  background: rgba(185, 146, 107, 0.05);
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.18s, transform 0.18s;
}
.mg-cell:hover { background: rgba(185, 146, 107, 0.14); }
.mg-cell.filled {
  background: var(--accent);
  opacity: 0.75;
}
.mg-cell.filled:hover { opacity: 1; }
.mg-cell.today {
  outline: 1.5px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- Login ---------- */

.login-screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 700px at 30% 20%, rgba(185, 146, 107, 0.14) 0%, transparent 55%),
    radial-gradient(700px 500px at 70% 80%, rgba(141, 108, 77, 0.10) 0%, transparent 55%),
    var(--bg);
  z-index: 1000;
  padding: 20px;
}
.login-screen.active { display: flex; }
body.locked > *:not(.login-screen) { display: none !important; }

.login-card {
  background: var(--surface);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-deep);
  text-align: center;
}
.login-card h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.6px;
  color: var(--accent-soft);
}
.login-hint {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
}
.login-card input[type=password] {
  background: rgba(34, 27, 21, 0.55);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 16px;
  font-size: 15px;
  font-family: inherit;
  text-align: center;
  letter-spacing: 0.4px;
}
.login-card input[type=password]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(185, 146, 107, 0.10);
}
.login-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 16px;
}

/* ---------- Scrollbars ---------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(185, 146, 107, 0.16); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(185, 146, 107, 0.28); }

::selection { background: rgba(185, 146, 107, 0.30); color: var(--text); }

/* ---------- Responsive ---------- */

@media (max-width: 800px) {
  .qn-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .qn-sidebar { max-height: 36vh; }
  .topbar { gap: 10px; padding: 14px 18px; }
  .motto { display: none; }
  .tabs { order: 3; width: 100%; justify-content: center; }
  main { padding: 28px 18px 70px; }
  .view-header h2 { font-size: 24px; }
  .brand { font-size: 20px; padding-right: 14px; }
  .brand::after { display: none; }
}
