:root {
  --bg:         #1a1a1a;
  --bg-card:    #242424;
  --bg-hover:   #2e2e2e;
  --bg-input:   #1f1f1f;
  --border:     #333333;
  --border-hi:  #444444;
  --text:       #e8e8e8;
  --text-dim:   #888888;
  --text-mid:   #b0b0b0;
  --danger:     #c87070;
  --radius:     6px;
  --shadow:     0 2px 10px rgba(0,0,0,0.3);
  --mono:       ui-monospace, "SF Mono", Menlo, monospace;
  --sans:       -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text); text-decoration: none; }
a:hover { color: #fff; }

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
}

button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
button:hover { background: var(--bg-hover); border-color: var(--border-hi); }
button.primary { background: #353535; }
button.primary:hover { background: #404040; }
button.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
button.ghost:hover { background: var(--bg-hover); color: var(--text); }
button.danger { color: var(--danger); }
button.danger:hover { background: #3a2828; border-color: #5a3030; }

input[type="text"], textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.12s;
}
input[type="text"]:focus, textarea:focus { border-color: var(--border-hi); }

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
}
.topbar h1 {
  font-size: 22px;
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.01em;
}
.topbar .crumbs {
  color: var(--text-dim);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .crumbs a:hover { color: var(--text); }
.topbar .crumbs .sep { opacity: 0.5; }

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

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.12s;
  display: block;
}
.card:hover { background: var(--bg-hover); border-color: var(--border-hi); }
.card .title { font-size: 16px; font-weight: 500; margin: 0 0 6px; color: var(--text); }
.card .desc { color: var(--text-mid); font-size: 13px; margin: 0 0 12px; min-height: 1.5em; }
.card .meta { color: var(--text-dim); font-size: 12px; display: flex; gap: 10px; }

.list { display: flex; flex-direction: column; gap: 2px; }
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.list-item:hover { background: var(--bg-hover); border-color: var(--border-hi); }
.list-item .title { font-weight: 500; }
.list-item .meta { color: var(--text-dim); font-size: 12px; }

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 60px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

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

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: min(560px, 92vw);
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow);
}
.modal h2 { margin: 0 0 16px; font-size: 18px; font-weight: 500; }
.modal .field { margin-bottom: 14px; }
.modal label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  width: 100%;
}

/* Note page */
.note-shell { max-width: 880px; margin: 0 auto; padding: 32px 24px 80px; }
.note-title {
  background: transparent;
  border: none;
  font-size: 28px;
  font-weight: 500;
  padding: 4px 0;
  margin-bottom: 16px;
  color: var(--text);
  width: 100%;
  outline: none;
  border-bottom: 1px solid transparent;
}
.note-title:focus { border-bottom-color: var(--border); }
.save-status {
  color: var(--text-dim);
  font-size: 12px;
  margin-left: 8px;
}

/* Toast UI editor dark theme overrides — keeps things consistent with our palette */
.toastui-editor-defaultUI {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
}
.toastui-editor-defaultUI .toastui-editor-toolbar,
.toastui-editor-defaultUI .toastui-editor-main {
  background: var(--bg-card) !important;
}
.toastui-editor-contents { font-size: 15px !important; }

/* Chart canvas inside editor (rendered after insert as <img>) */
.chart-preview { max-width: 100%; margin: 16px auto; display: block; }
