* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  background: #0f1115;
  color: #e6e8eb;
  line-height: 1.5;
}

.layout { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: #131720;
  border-right: 1px solid #1f2532;
  padding: 20px 16px;
  overflow-y: auto;
  position: sticky;
  top: 0;
  max-height: 100vh;
}
.sidebar h2 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8a90a0;
}
.sidebar-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.sidebar-item {
  display: grid;
  grid-template-columns: 12px 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}
.sidebar-item:hover { background: #181c24; border-color: #2a3040; }
.sidebar-item.is-recent { background: #1a2030; border-color: #2a3450; }
.sidebar-item.is-disabled .sidebar-title { color: #8a90a0; text-decoration: line-through; }
.sidebar-title {
  font-size: 14px; color: #e6e8eb;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  grid-column: 2;
}
.sidebar-date { font-size: 11px; color: #8a90a0; grid-column: 2; }
.sidebar .empty { color: #8a90a0; font-style: italic; padding: 6px 10px; list-style: none; }

.dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #6ec07a;
  vertical-align: middle;
  flex-shrink: 0;
}
.dot-on  { background: #6ec07a; box-shadow: 0 0 6px rgba(110,192,122,0.4); }
.dot-off { background: #555c6b; box-shadow: none; }
.sidebar-item .dot { grid-row: 1 / span 2; grid-column: 1; }

.content { max-width: 760px; margin: 0 auto; width: 100%; padding: 32px 24px 80px; }
h1 { margin: 0 0 4px; font-size: 28px; }
.hint { margin: 0 0 24px; color: #8a90a0; font-size: 14px; }
.section-title { margin: 32px 0 12px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: #8a90a0; }

#add-form { margin-bottom: 8px; display: flex; flex-direction: column; gap: 8px; }
input[type="text"], textarea {
  width: 100%;
  background: #181c24;
  color: #e6e8eb;
  border: 1px solid #2a3040;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
}
textarea { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; resize: vertical; }
input[type="text"]:focus, textarea:focus { outline: none; border-color: #5b8def; }
.actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
button {
  background: #5b8def; color: white; border: 0;
  padding: 8px 16px; border-radius: 6px;
  font-size: 14px; cursor: pointer; font-family: inherit;
}
button:hover { background: #4a7adc; }
button.secondary { background: transparent; color: #8a90a0; border: 1px solid #2a3040; }
button.secondary:hover { background: #181c24; color: #e6e8eb; }
button.danger { color: #e26b6b; border-color: #4a2a30; }
button.danger:hover { background: #2a1a1f; color: #ff8a8a; }
.msg { font-size: 13px; color: #6ec07a; }
.msg.error { color: #e26b6b; }

.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.item {
  background: #181c24;
  border: 1px solid #2a3040;
  border-radius: 8px;
  padding: 14px 16px;
}
.item.is-disabled { opacity: 0.6; }
.item-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; font-size: 12px; color: #8a90a0;
  flex-wrap: wrap; gap: 8px;
}
.item-head .row { display: flex; gap: 6px; }
.item-title { margin: 0 0 8px; font-size: 16px; color: #e6e8eb; }
.item.is-disabled .item-title { text-decoration: line-through; }
.item pre {
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px; white-space: pre-wrap; word-break: break-word;
  max-height: 280px; overflow: auto;
}
.empty { color: #8a90a0; font-style: italic; }

/* Toggle switch */
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track {
  width: 36px; height: 20px;
  background: #2a3040; border-radius: 999px;
  position: relative; transition: background 0.15s;
}
.toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #555c6b;
  border-radius: 50%; transition: transform 0.15s, background 0.15s;
}
.toggle input:checked + .toggle-track { background: #1f3a26; }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); background: #6ec07a; box-shadow: 0 0 6px rgba(110,192,122,0.4); }
.toggle-label { font-size: 13px; color: #8a90a0; }

/* Modals */
dialog.modal {
  border: 1px solid #2a3040;
  background: #181c24;
  color: #e6e8eb;
  border-radius: 12px;
  padding: 0;
  width: min(640px, 92vw);
  max-height: 86vh;
}
dialog.modal::backdrop { background: rgba(0,0,0,0.55); }
.modal-body { display: flex; flex-direction: column; gap: 12px; padding: 20px; max-height: 86vh; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-meta { font-size: 12px; color: #8a90a0; }
#detail-text {
  margin: 0;
  background: #0f1115;
  border: 1px solid #2a3040;
  border-radius: 8px;
  padding: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px; white-space: pre-wrap; word-break: break-word;
  overflow: auto; flex: 1 1 auto; min-height: 120px;
}
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: 240px; border-right: 0; border-bottom: 1px solid #1f2532; }
}
