/* ===== CSS Variables - Dark Theme (Catppuccin Mocha) ===== */
:root {
  --bg-primary: #1e1e2e;
  --bg-secondary: #181825;
  --bg-tertiary: #313244;
  --bg-hover: #45475a;
  --text-primary: #cdd6f4;
  --text-secondary: #a6adc8;
  --text-muted: #6c7086;
  --accent: #89b4fa;
  --accent-hover: #74c7ec;
  --accent-dim: rgba(137, 180, 250, 0.15);
  --green: #a6e3a1;
  --red: #f38ba8;
  --yellow: #f9e2af;
  --peach: #fab387;
  --mauve: #cba6f7;
  --border: #45475a;
  --sidebar-width: 330px;
  --topbar-height: 48px;
}

/* ===== Light Theme (Catppuccin Latte) ===== */
:root.light {
  --bg-primary: #eff1f5;
  --bg-secondary: #e6e9ef;
  --bg-tertiary: #ccd0da;
  --bg-hover: #bcc0cc;
  --text-primary: #4c4f69;
  --text-secondary: #5c5f77;
  --text-muted: #9ca0b0;
  --accent: #1e66f5;
  --accent-hover: #2a6ef5;
  --accent-dim: rgba(30, 102, 245, 0.1);
  --green: #40a02b;
  --red: #d20f39;
  --yellow: #df8e1d;
  --border: #ccd0da;
}

:root.light .hljs { background: #e6e9ef !important; }

/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
}

button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input, textarea { font: inherit; color: inherit; background: inherit; border: none; outline: none; }
a { color: var(--accent); text-decoration: none; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }

/* ===== App Layout ===== */
.app { display: flex; height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width); min-width: var(--sidebar-width);
  background: var(--bg-secondary); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; transition: margin-left 0.3s;
}
.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-width)); }
.sidebar-header { padding: 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.sidebar-header h1 { font-size: 16px; font-weight: 700; color: var(--accent); flex: 1; }
.sidebar-search { padding: 12px 16px; }
.sidebar-search input {
  width: 100%; padding: 8px 12px; background: var(--bg-tertiary);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text-primary); font-size: 13px;
}
.sidebar-search input::placeholder { color: var(--text-muted); }
.sidebar-search input:focus { border-color: var(--accent); }

/* Tag Section */
.tag-section { border-bottom: 1px solid var(--border); }
.tag-section-header {
  display: flex; align-items: center; gap: 6px; padding: 8px 16px; cursor: pointer;
  font-size: 11px; font-weight: 600; color: var(--text-muted); transition: color 0.15s;
}
.tag-section-header:hover { color: var(--text-primary); }
.tag-filter { padding: 4px 16px 10px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag-chip { font-size: 11px; padding: 2px 8px; border-radius: 12px; border: 1px solid var(--border); color: var(--text-secondary); cursor: pointer; transition: all 0.2s; }
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* ===== Folder Notes Panel (second sidebar) ===== */
.folder-notes-panel {
  width: 280px; min-width: 280px; max-width: 280px; background: var(--bg-secondary);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  flex-shrink: 0; transition: width 0.2s, min-width 0.2s, max-width 0.2s;
}
.folder-notes-panel.collapsed { width: 0; min-width: 0; max-width: 0; border-right: none; overflow: hidden; }
.folder-notes-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.folder-notes-header .folder-notes-title {
  flex: 1; font-size: 13px; font-weight: 700; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.folder-notes-header button { padding: 4px; border-radius: 4px; color: var(--text-muted); }
.folder-notes-header button:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.folder-notes-list { flex: 1; overflow-y: auto; padding: 8px; }
.folder-notes-list::-webkit-scrollbar { width: 6px; }
.folder-notes-list::-webkit-scrollbar-track { background: transparent; }
.folder-notes-list::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
.folder-notes-list::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Note List */
.note-list { padding: 8px; }
.note-item { padding: 10px 12px; border-radius: 8px; cursor: pointer; transition: background 0.15s; margin-bottom: 2px; position: relative; display: flex; align-items: flex-start; gap: 6px; }
.note-item:hover { background: var(--bg-tertiary); }
.note-item.active { background: var(--accent-dim); }
.note-item-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item-title .pin { color: var(--yellow); font-size: 12px; display: inline-flex; align-items: center; }
.note-item-meta { font-size: 11px; color: var(--text-muted); }
.note-item-tags { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.note-item-tags span { font-size: 10px; padding: 1px 6px; border-radius: 8px; background: var(--bg-tertiary); color: var(--text-secondary); }

/* Sidebar Top Actions */
.sidebar-top-actions { padding: 12px 16px 8px; border-bottom: 1px solid var(--border); }
.btn-new-note {
  width: 100%; padding: 10px; background: var(--accent); color: var(--bg-secondary);
  border-radius: 8px; font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: center; gap: 6px; transition: background 0.2s;
}
.btn-new-note:hover { background: var(--accent-hover); }

/* Sidebar Scrollable Area */
.sidebar-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
.sidebar-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Sidebar Tabs ===== */
.sidebar-tabs {
  display: flex; border-bottom: 1px solid var(--border); padding: 0 8px;
}
.sidebar-tab {
  flex: 1; padding: 8px 0; font-size: 12px; font-weight: 600; text-align: center;
  color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent;
  transition: all 0.15s; display: flex; align-items: center; justify-content: center; gap: 4px;
}
.sidebar-tab:hover { color: var(--text-primary); }
.sidebar-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== To-do Panel ===== */
.todo-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.todo-toolbar {
  padding: 8px 12px; display: flex; gap: 6px; align-items: center; border-bottom: 1px solid var(--border);
}
.todo-toolbar select {
  padding: 4px 6px; font-size: 11px; background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-primary); cursor: pointer;
}
.todo-toolbar select:focus { border-color: var(--accent); outline: none; }
.todo-sort-btn {
  padding: 4px 8px; font-size: 11px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-tertiary); color: var(--text-secondary);
  display: flex; align-items: center; gap: 3px; white-space: nowrap; transition: all 0.15s;
}
.todo-sort-btn:hover { border-color: var(--accent); color: var(--accent); }
.todo-sort-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.todo-deadline-group { margin: 6px 10px 8px; }
.todo-deadline-group .todo-item { border-radius: 6px; }
.todo-add-bar {
  padding: 8px 12px; display: flex; gap: 6px; align-items: center;
}
.todo-add-bar input {
  flex: 1; padding: 7px 10px; font-size: 12px; background: var(--bg-tertiary);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text-primary);
}
.todo-add-bar input:focus { border-color: var(--accent); }
.todo-add-bar input::placeholder { color: var(--text-muted); }
.todo-add-btn {
  padding: 6px 10px; background: var(--accent); color: var(--bg-secondary); border-radius: 8px;
  font-size: 12px; font-weight: 600; white-space: nowrap; transition: background 0.15s;
}
.todo-add-btn:hover { background: var(--accent-hover); }
.todo-scroll { flex: 1; overflow-y: auto; padding: 4px 0; }
.todo-scroll::-webkit-scrollbar { width: 6px; }
.todo-scroll::-webkit-scrollbar-track { background: transparent; }
.todo-scroll::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
.todo-category-group { margin-bottom: 4px; }
.todo-category-header {
  padding: 6px 14px; font-size: 11px; font-weight: 700; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px; cursor: pointer;
}
.todo-category-header:hover { color: var(--text-primary); }
.todo-category-count {
  font-size: 10px; padding: 0 5px; border-radius: 8px; background: var(--bg-tertiary);
  color: var(--text-muted); font-weight: 600;
}
.todo-item {
  display: flex; align-items: flex-start; gap: 8px; padding: 6px 14px; cursor: pointer;
  transition: background 0.1s; font-size: 12px; position: relative;
}
.todo-item:hover { background: var(--bg-tertiary); }
.todo-item.completed .todo-title { text-decoration: line-through; color: var(--text-muted); }
.todo-checkbox {
  width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--border);
  flex-shrink: 0; margin-top: 1px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s;
}
.todo-checkbox:hover { border-color: #a6e3a1; }
.todo-checkbox.checked { background: #a6e3a1; border-color: #a6e3a1; }
.todo-item-body { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.todo-title { flex: 1; line-height: 1.4; word-break: break-word; }
.todo-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.todo-priority {
  font-size: 9px; padding: 1px 5px; border-radius: 4px; font-weight: 700; line-height: 1.4;
}
.todo-priority.high { background: rgba(243,139,168,0.2); color: var(--red); }
.todo-priority.medium { background: rgba(249,226,175,0.2); color: var(--yellow); }
.todo-priority.low { background: rgba(166,227,161,0.2); color: var(--green); }
.todo-priority-group {
  margin: 6px 10px 8px; border-radius: 8px; border-left: 3px solid; overflow: hidden;
}
.todo-priority-group.high { border-color: var(--red); }
.todo-priority-group.medium { border-color: var(--yellow); }
.todo-priority-group.low { border-color: var(--green); }
.todo-priority-header {
  padding: 5px 10px; font-size: 11px; font-weight: 700; display: flex; align-items: center; gap: 6px;
}
.todo-priority-header.high { color: var(--red); background: rgba(243,139,168,0.06); }
.todo-priority-header.medium { color: var(--yellow); background: rgba(249,226,175,0.06); }
.todo-priority-header.low { color: var(--green); background: rgba(166,227,161,0.06); }
.todo-due {
  font-size: 10px; color: var(--text-muted); display: flex; align-items: center; gap: 2px;
}
.todo-due.overdue { color: var(--red); }
.todo-due.today { color: var(--peach); }
.todo-item-actions {
  display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; flex-shrink: 0;
}
.todo-item:hover .todo-item-actions { opacity: 1; }
.todo-item-actions button {
  padding: 2px; border-radius: 4px; color: var(--text-muted);
}
.todo-item-actions button:hover { color: var(--red); background: rgba(243,139,168,0.15); }
.todo-empty {
  text-align: center; color: var(--text-muted); font-size: 12px; padding: 32px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.todo-stats {
  padding: 8px 14px; border-top: 1px solid var(--border); font-size: 11px;
  color: var(--text-muted); display: flex; justify-content: space-between;
}
/* Todo edit inline */
.todo-edit-row {
  padding: 6px 12px; background: var(--bg-tertiary); border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}
.todo-edit-row select {
  padding: 5px 8px; font-size: 11px; background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-primary);
}
.todo-edit-row select:focus { border-color: var(--accent); outline: none; }
.todo-edit-controls { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.todo-date-btn {
  padding: 4px 8px; border-radius: 6px; font-size: 11px;
  background: var(--bg-primary); border: 1px solid var(--border); color: var(--text-secondary);
  cursor: pointer; display: flex; align-items: center; gap: 4px; transition: all 0.15s;
}
.todo-date-btn:hover { border-color: var(--accent); color: var(--accent); }
.todo-date-btn.has-date { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.todo-date-hidden { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }
.todo-date-clear {
  padding: 2px 4px; font-size: 12px; color: var(--text-muted); cursor: pointer; line-height: 1;
  font-weight: 700;
}
.todo-date-clear:hover { color: var(--red); }
.todo-fold-btn {
  padding: 4px 6px; font-size: 11px; color: var(--text-muted); cursor: pointer;
  border-radius: 4px; transition: all 0.15s; margin-left: auto;
}
.todo-fold-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

/* ===== Main Content ===== */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* Top Bar */
.topbar {
  height: var(--topbar-height); display: flex; align-items: center;
  padding: 0 16px; gap: 8px; border-bottom: 1px solid var(--border); background: var(--bg-secondary);
}
.topbar-btn { padding: 6px; border-radius: 6px; color: var(--text-secondary); transition: all 0.15s; display: flex; align-items: center; }
.topbar-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.topbar-btn.active { color: var(--accent); background: var(--accent-dim); }
.topbar-btn.refresh-btn:hover { background: rgba(166,227,161,0.15); color: #a6e3a1; }
.topbar-title { flex: 1; font-size: 14px; font-weight: 600; }
.topbar-title input {
  width: 100%; font-size: 14px; font-weight: 600;
  background: var(--bg-tertiary); padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px;
}
.topbar-title input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }

/* Content Area */
.content-area { flex: 1; overflow-y: auto; padding: 32px; max-width: 860px; margin: 0 auto; width: 100%; position: relative; }

/* Editor */
.editor-container { height: 100%; display: flex; flex-direction: column; }
.tag-input-row { display: flex; align-items: center; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.tag-input-row .tag-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 3px 10px; border-radius: 12px; background: var(--accent-dim); color: var(--accent); }
.tag-badge button { font-size: 14px; line-height: 1; color: var(--text-muted); padding: 0 2px; }
.tag-badge button:hover { color: var(--red); }
.tag-input-row input { font-size: 12px; padding: 3px 8px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 8px; min-width: 100px; }
.tag-input-row input:focus { border-color: var(--accent); }
/* ===== Markdown Toolbar ===== */
.md-toolbar {
  display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 8px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: 10px 10px 0 0; border-bottom: none;
}
.md-toolbar-btn {
  padding: 4px 8px; font-size: 12px; font-weight: 600; border-radius: 6px;
  background: transparent; color: var(--text-secondary); cursor: pointer;
  transition: all 0.15s; border: 1px solid transparent; min-width: 28px;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
}
.md-toolbar-btn:hover { background: var(--bg-secondary); color: var(--accent); border-color: var(--border); }

/* Highlight palette */
.highlight-palette {
  position: absolute; top: 100%; left: 0; z-index: 10;
  display: flex; gap: 4px; padding: 8px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  margin-top: 4px;
}
.highlight-color-btn {
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: all 0.15s;
}
.highlight-color-btn:hover { border-color: var(--text-primary); transform: scale(1.2); }
.highlight-remove-btn {
  background: var(--bg-tertiary) !important; position: relative;
  border: 2px dashed var(--text-muted) !important;
}
.highlight-remove-btn::before, .highlight-remove-btn::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 12px; height: 2px; background: var(--text-muted); border-radius: 1px;
}
.highlight-remove-btn::before { transform: translate(-50%,-50%) rotate(45deg); }
.highlight-remove-btn::after { transform: translate(-50%,-50%) rotate(-45deg); }
.highlight-remove-btn:hover { border-color: var(--red) !important; }
.highlight-remove-btn:hover::before, .highlight-remove-btn:hover::after { background: var(--red); }

/* Highlight manager panel */
.highlight-manager-panel {
  position: absolute; top: 100%; right: 0; z-index: 10;
  width: 300px; background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  margin-top: 4px;
}
.highlight-manager-item:hover { background: var(--bg-tertiary); }

/* Read mode floating highlight palette */
.read-highlight-palette {
  position: absolute; z-index: 20; transform: translateX(-50%);
  display: flex; gap: 3px; padding: 6px 8px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  animation: fadeInPalette 0.15s ease;
}
.read-highlight-palette::after {
  content: ""; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-top: 6px solid var(--bg-secondary);
}
@keyframes fadeInPalette { from { opacity: 0; transform: translateX(-50%) translateY(4px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* Markdown highlight (==text==) */
.markdown-body mark { color: #1e1e2e; padding: 1px 4px; border-radius: 3px; }

.editor-textarea {
  flex: 1; width: 100%; resize: none;
  background: var(--bg-secondary); color: var(--text-primary);
  font-size: 15px; line-height: 1.8; font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  padding: 20px; border: 1px solid var(--border); border-radius: 0 0 10px 10px;
}
.editor-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
.editor-textarea::placeholder { color: var(--text-muted); }

/* ===== Markdown Rendered View ===== */
.markdown-body { color: var(--text-primary); line-height: 1.8; font-size: 15px; }
.markdown-body h1 { font-size: 2em; margin: 0.8em 0 0.4em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; color: var(--accent); }
.markdown-body h2 { font-size: 1.5em; margin: 0.8em 0 0.4em; color: var(--text-primary); }
.markdown-body h3 { font-size: 1.25em; margin: 0.6em 0 0.3em; }
.markdown-body p { margin: 0.6em 0; }
.markdown-body ul, .markdown-body ol { padding-left: 1.5em; margin: 0.5em 0; }
.markdown-body li { margin: 0.25em 0; }
.markdown-body input[type="checkbox"] { cursor: pointer; width: 16px; height: 16px; accent-color: #a6e3a1; vertical-align: middle; margin-right: 4px; }
.markdown-body blockquote { border-left: 3px solid var(--accent); padding: 0.5em 1em; margin: 0.8em 0; background: var(--accent-dim); border-radius: 0 8px 8px 0; color: var(--text-secondary); }
.markdown-body code { background: var(--bg-tertiary); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace; }
.markdown-body pre { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 16px; overflow-x: auto; margin: 0.8em 0; }
.markdown-body pre code { background: none; padding: 0; }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 0.8em 0; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.markdown-body th { background: var(--bg-tertiary); font-weight: 600; }
.markdown-body img { max-width: 100%; border-radius: 8px; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }
.markdown-body details { background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; margin: 0.8em 0; }
.markdown-body details summary { cursor: pointer; font-weight: 600; color: var(--accent); user-select: none; }
.markdown-body details summary:hover { color: var(--accent-hover); }
.markdown-body details[open] summary { margin-bottom: 8px; }
.markdown-body .katex-display { overflow-x: auto; padding: 8px 0; }
.markdown-body strong { color: var(--text-primary); font-weight: 700; }
.markdown-body em { color: var(--text-secondary); }
.markdown-body del { color: var(--text-muted); }
.markdown-body a { color: var(--accent); }
.markdown-body a:hover { text-decoration: underline; }

/* ===== Empty State ===== */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); gap: 16px; }
.empty-state svg { opacity: 0.3; }
.empty-state p { font-size: 15px; }

/* ===== Setup Screen ===== */
.setup-screen { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--bg-primary); }
.setup-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 16px; padding: 40px; max-width: 480px; width: 90%; }
.setup-card h2 { font-size: 22px; margin-bottom: 8px; color: var(--accent); }
.setup-card p { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; line-height: 1.6; }
.setup-field { margin-bottom: 16px; }
.setup-field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.setup-field input { width: 100%; padding: 10px 14px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.setup-field input:focus { border-color: var(--accent); }
.setup-btn { width: 100%; padding: 12px; background: var(--accent); color: var(--bg-secondary); border-radius: 10px; font-weight: 700; font-size: 15px; margin-top: 8px; transition: background 0.2s; }
.setup-btn:hover { background: var(--accent-hover); }
.setup-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.setup-error { color: var(--red); font-size: 13px; margin-bottom: 12px; }

/* ===== Toast ===== */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 10px; padding: 12px 20px; font-size: 13px; color: var(--text-primary); z-index: 9999; animation: slideUp 0.3s ease; display: flex; align-items: center; gap: 8px; }
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ===== Confirm Dialog ===== */
.confirm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.confirm-dialog { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 12px; padding: 24px; max-width: 360px; width: 90%; }
.confirm-dialog h3 { margin-bottom: 8px; font-size: 16px; }
.confirm-dialog p { color: var(--text-secondary); font-size: 14px; margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }
.confirm-actions button { padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.btn-cancel { background: var(--bg-tertiary); }
.btn-cancel:hover { background: var(--bg-hover); }
.btn-danger { background: var(--red); color: var(--bg-primary); }
.btn-danger:hover { opacity: 0.9; }

/* ===== Action Bar (읽기 모드 상단) ===== */
.action-bar { display: flex; gap: 6px; margin-bottom: 28px; flex-wrap: wrap; }
.action-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
  transition: all 0.15s; border: 1px solid var(--border); background: var(--bg-tertiary); color: var(--text-secondary);
  line-height: 1; vertical-align: middle;
}
.action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.action-btn span { display: inline-flex; align-items: center; }
.action-btn-edit { background: var(--accent-dim); color: var(--accent); border-color: transparent; }
.action-btn-edit:hover { background: var(--accent); color: var(--bg-secondary); border-color: transparent; }
.action-btn-delete:hover { background: rgba(243,139,168,0.15); color: var(--red); border-color: var(--red); }

/* Note item hover delete */
.note-item { position: relative; }
.note-item-delete { position: absolute; top: 8px; right: 4px; padding: 4px; border-radius: 4px; color: var(--text-muted); opacity: 0; transition: all 0.15s; background: var(--bg-secondary); }
.note-item:hover .note-item-delete { opacity: 1; }
.note-item-delete:hover { color: var(--red); background: rgba(243,139,168,0.15); }
.note-item-check {
  flex-shrink: 0; width: 14px; height: 14px; cursor: pointer; margin-right: 4px;
  accent-color: var(--text-muted); appearance: none; -webkit-appearance: none;
  background: var(--bg-tertiary); border: 1.5px solid var(--border); border-radius: 3px;
  position: relative;
}
.note-item-check:checked {
  background: var(--accent); border-color: var(--accent);
}
.note-item-check:checked::after {
  content: "✓"; position: absolute; top: -1px; left: 1.5px;
  font-size: 10px; color: var(--bg-primary); font-weight: 700;
}
.bulk-action-bar {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  border-bottom: 1px solid var(--border); background: var(--bg-tertiary); font-size: 11px;
}
.bulk-action-bar span { color: var(--text-secondary); flex: 1; }
.bulk-action-bar button { padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; transition: all 0.15s; }
.bulk-btn-download { background: var(--accent-dim); color: var(--accent); }
.bulk-btn-download:hover { background: var(--accent); color: var(--bg-primary); }
.bulk-btn-delete { background: rgba(243,139,168,0.12); color: var(--red); }
.bulk-btn-delete:hover { background: var(--red); color: #1e1e2e; }

/* Sort Bar */
.sort-bar { display: flex; align-items: center; gap: 4px; padding: 6px 12px; border-bottom: 1px solid var(--border); }
.sort-bar select {
  flex: 1; padding: 4px 8px; font-size: 11px; background: var(--bg-tertiary);
  border: 1px solid var(--border); border-radius: 6px; color: var(--text-primary); cursor: pointer;
}
.sort-bar select:focus { border-color: var(--accent); outline: none; }
.channel-group-header {
  padding: 6px 12px; font-size: 11px; font-weight: 700; color: var(--accent);
  background: var(--bg-tertiary); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1;
}

/* ===== Folder Tree ===== */
.folder-section { padding: 8px 8px 0; }
.folder-section-header { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; margin-bottom: 2px; }
.folder-section-header span { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.folder-section-header button { padding: 2px; border-radius: 4px; color: var(--text-muted); }
.folder-section-header button:hover { color: var(--accent); background: var(--accent-dim); }
.folder-item { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text-secondary); transition: all 0.15s; position: relative; }
.folder-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.folder-item.active { background: var(--accent-dim); color: var(--accent); }
.folder-item.folder-drop-target { background: var(--accent-dim); border: 1px dashed var(--accent); border-radius: 6px; }
.folder-item.folder-dragging { opacity: 0.4; }
.folder-item.note-drop-target { background: rgba(166,227,161,0.15); border: 1px dashed var(--green); border-radius: 6px; }
.folder-item .folder-count { font-size: 10px; color: var(--text-muted); margin-left: auto; padding-right: 2px; }
.folder-item:hover .folder-count { display: none; }
.folder-item-actions { margin-left: auto; display: flex; gap: 2px; opacity: 0; }
.folder-item:hover .folder-item-actions { opacity: 1; }
.folder-item-actions button { padding: 3px; border-radius: 4px; color: var(--text-muted); }
.folder-item-actions button:hover { color: var(--accent); background: var(--accent-dim); }
.folder-item-actions button:last-child:hover { color: var(--red); background: rgba(243,139,168,0.15); }
.folder-input { width: 100%; padding: 5px 8px; font-size: 13px; background: var(--bg-tertiary); border: 1px solid var(--accent); border-radius: 6px; color: var(--text-primary); }
.folder-divider { height: 1px; background: var(--border); margin: 8px 16px; }

/* ===== Frontmatter Editor ===== */
.frontmatter-toggle {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; margin-bottom: 12px;
  background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; color: var(--text-secondary); cursor: pointer; transition: all 0.15s; width: fit-content;
}
.frontmatter-toggle:hover { border-color: var(--accent); color: var(--accent); }
.frontmatter-toggle.has-data { border-color: var(--green); color: var(--green); }
.fm-fields { margin-bottom: 16px; }
.fm-field-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.fm-field-key {
  min-width: 130px; width: 130px; font-size: 12px; font-weight: 600;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  color: var(--accent); padding: 6px 0; flex-shrink: 0; text-align: right;
}
.fm-field-val {
  flex: 1; padding: 6px 10px; font-size: 13px;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  background: var(--bg-secondary); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 6px; transition: border-color 0.15s;
}
.fm-field-val:focus { border-color: var(--mauve); box-shadow: 0 0 0 2px rgba(203,166,247,0.12); }
.fm-field-val::placeholder { color: var(--text-muted); }
.fm-field-del {
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; color: var(--text-muted); font-size: 16px; font-weight: 600;
  transition: all 0.15s; flex-shrink: 0; line-height: 1;
}
.fm-field-del:hover { color: var(--red); background: rgba(243,139,168,0.15); }
.fm-add-btn {
  display: flex; align-items: center; gap: 4px; padding: 5px 10px; font-size: 11px;
  color: var(--text-muted); border: 1px dashed var(--border); border-radius: 6px;
  margin-top: 4px; transition: all 0.15s; width: fit-content;
}
.fm-add-btn:hover { border-color: var(--accent); color: var(--accent); }
.frontmatter-display {
  background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; margin-bottom: 20px; font-size: 13px; line-height: 1.7;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace; color: var(--mauve);
  white-space: pre-wrap; overflow-x: auto;
}
.frontmatter-display .fm-key { color: var(--accent); }
.frontmatter-display .fm-val { color: var(--text-secondary); }

/* ===== AI Chat Panel (Right Sidebar) ===== */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.chat-msg {
  max-width: 90%; padding: 10px 14px; border-radius: 14px; font-size: 13px; line-height: 1.6;
  word-break: break-word;
}
.chat-msg.user {
  align-self: flex-end; background: var(--accent); color: #1e1e2e; border-bottom-right-radius: 4px;
}
.chat-msg.ai {
  align-self: flex-start; background: var(--bg-tertiary); color: var(--text-primary); border-bottom-left-radius: 4px;
}
.chat-msg.ai .markdown-body { font-size: 13px; }
.chat-msg.ai .markdown-body p { margin: 0 0 8px; }
.chat-msg.ai .markdown-body p:last-child { margin: 0; }
.chat-msg.ai .markdown-body code { font-size: 12px; background: var(--bg-primary); padding: 1px 4px; border-radius: 4px; }
.chat-source-btn {
  display: inline-block; margin: 4px 0; padding: 4px 8px; font-size: 11px; line-height: 1.4;
  background: rgba(137,180,250,0.12); border: 1px solid rgba(137,180,250,0.25); border-radius: 6px;
  color: var(--accent); cursor: pointer; transition: all 0.15s; text-align: left; word-break: break-word;
}
.chat-source-btn:hover { background: rgba(137,180,250,0.25); border-color: var(--accent); }
mark.chat-highlight {
  background: rgba(249,226,175,0.35); color: inherit; padding: 2px 4px; border-radius: 3px;
  border-bottom: 2px solid var(--yellow); animation: highlightFade 8s forwards;
}
@keyframes highlightFade { 0%,80% { opacity: 1; } 100% { opacity: 0; } }
.chat-msg.system {
  align-self: center; background: none; color: var(--text-muted); font-size: 11px;
  text-align: center; padding: 4px; font-style: italic;
}
.chat-typing {
  align-self: flex-start; padding: 10px 14px; background: var(--bg-tertiary); border-radius: 14px;
  border-bottom-left-radius: 4px; display: flex; gap: 4px; align-items: center;
}
.chat-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted);
  animation: chatBounce 1.4s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
.chat-input-area {
  padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: flex-end;
}
.chat-input-area textarea {
  flex: 1; resize: none; padding: 10px 12px; font-size: 13px; line-height: 1.5;
  background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text-primary); max-height: 100px; min-height: 40px;
}
.chat-input-area textarea:focus { border-color: var(--mauve); box-shadow: 0 0 0 2px rgba(203,166,247,0.15); }
.chat-input-area textarea::placeholder { color: var(--text-muted); }
.chat-send-btn {
  width: 36px; height: 36px; border-radius: 10px; background: var(--mauve); color: #1e1e2e;
  display: flex; align-items: center; justify-content: center; transition: all 0.15s; flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--accent); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; gap: 12px; color: var(--text-muted); text-align: center; padding: 32px; }
.chat-empty p { font-size: 12px; line-height: 1.5; }
.chat-model-selector {
  padding: 6px 12px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border);
}
.chat-model-selector label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.chat-model-selector select {
  flex: 1; padding: 5px 8px; font-size: 12px; border-radius: 6px;
  background: var(--bg-tertiary); border: 1px solid var(--border); color: var(--text-primary);
  cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239399b2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; padding-right: 24px;
}
.chat-model-selector select:focus { border-color: var(--mauve); outline: none; box-shadow: 0 0 0 2px rgba(203,166,247,0.15); }
.chat-model-hint {
  font-size: 10px; color: var(--text-muted); padding: 2px 12px 4px; line-height: 1.3; font-style: italic;
}

/* ===== Right Panel Shared ===== */
.right-panel {
  width: 380px; min-width: 380px; max-width: 380px; background: var(--bg-secondary);
  border-left: 1px solid var(--border); display: flex; flex-direction: column;
  flex-shrink: 0; overflow: hidden;
}
.right-panel.collapsed { width: 0; min-width: 0; max-width: 0; border-left: none; }
.right-panel-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

/* ===== Calendar ===== */
.cal-view-toggle {
  display: flex; padding: 4px 16px 0; gap: 4px;
}
.cal-view-btn {
  padding: 3px 10px; font-size: 12px; font-weight: 600; border-radius: 6px;
  color: var(--text-muted); cursor: pointer; transition: all 0.15s;
  border: 1px solid transparent;
}
.cal-view-btn:hover { color: var(--text-primary); }
.cal-view-btn.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.cal-header { display: flex; align-items: center; padding: 8px 16px; gap: 8px; }
.cal-header .cal-title { flex: 1; text-align: center; font-size: 14px; font-weight: 700; color: var(--text-primary); }
.cal-header button { padding: 4px 8px; border-radius: 6px; color: var(--text-secondary); font-size: 16px; }
.cal-header button:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.cal-week-view-day {
  display: flex; flex-direction: column; align-items: center; padding: 6px 2px; border-radius: 8px;
  cursor: pointer; transition: all 0.12s; position: relative; min-height: 120px; overflow: hidden; min-width: 0;
}
.cal-week-view-day:hover { background: var(--bg-tertiary); }
.cal-week-view-day .cal-wv-label { font-size: 11px; color: var(--text-muted); margin-bottom: 1px; }
.cal-week-view-day .cal-wv-num { font-size: 15px; font-weight: 700; color: var(--text-secondary); margin-bottom: 4px; }
.cal-week-view-day.today .cal-wv-num { color: var(--accent); }
.cal-week-view-day.selected { background: var(--mauve); }
.cal-week-view-day.selected .cal-wv-label { color: rgba(30,30,46,0.7); }
.cal-week-view-day.selected .cal-wv-num { color: #1e1e2e; }
.cal-wv-events { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 0 2px; overflow: hidden; }
.cal-wv-evt { font-size: 9px; padding: 1px 3px; border-radius: 3px; color: #1e1e2e; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.5; }
.cal-wv-evt.timed { background: var(--bg-tertiary); color: var(--text-secondary); font-weight: 500; }
.cal-week-view-day.selected .cal-wv-evt.timed { background: rgba(30,30,46,0.15); color: #1e1e2e; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); padding: 0 8px; }
.cal-weekdays span {
  text-align: center; font-size: 12px; font-weight: 600; color: var(--text-muted);
  padding: 6px 0;
}
.cal-grid { display: flex; flex-direction: column; padding: 0 8px 8px; user-select: none; }
.cal-week-row { position: relative; display: grid; grid-template-columns: repeat(7, 1fr); gap: 0 2px; }
.cal-multiday-bar {
  position: absolute; height: 14px; font-size: 8px; color: #1e1e2e; font-weight: 600;
  padding: 0 3px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  line-height: 14px; z-index: 2; pointer-events: none;
}
.cal-day {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 4px 2px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text-secondary);
  transition: all 0.12s; position: relative;
}
.cal-day:hover { background: var(--bg-tertiary); }
.cal-day.other-month { color: var(--text-muted); opacity: 0.4; }
.cal-day.today { background: var(--accent-dim); color: var(--accent); font-weight: 700; }
.cal-day.selected { background: var(--mauve); color: #1e1e2e; font-weight: 700; }
.cal-day.selected:hover { background: var(--mauve); }
.cal-day .cal-dot {
  width: 4px; height: 4px; border-radius: 50%; background: var(--peach);
  margin-top: 2px;
}
.cal-day.selected .cal-dot { background: #1e1e2e; }
.cal-events { padding: 0 16px; }
.cal-events-header {
  font-size: 14px; font-weight: 700; color: var(--text-primary);
  padding: 12px 0 8px; border-bottom: 1px solid var(--border); margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.cal-event-item {
  display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px;
  background: var(--bg-tertiary); border-radius: 8px; margin-bottom: 6px;
  font-size: 13px; transition: all 0.12s;
}
.cal-event-item:hover { background: var(--bg-hover); }
.cal-event-color { width: 4px; min-height: 24px; border-radius: 2px; flex-shrink: 0; margin-top: 2px; }
.cal-event-body { flex: 1; }
.cal-event-title { font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.cal-event-time { color: var(--text-muted); font-size: 12px; }
.cal-event-del { padding: 2px; border-radius: 4px; color: var(--text-muted); opacity: 0; flex-shrink: 0; }
.cal-event-item:hover .cal-event-del { opacity: 1; }
.cal-event-del:hover { color: var(--red); background: rgba(243,139,168,0.15); }
.cal-add-form {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.cal-add-form input, .cal-add-form select {
  padding: 8px 10px; font-size: 12px; background: var(--bg-tertiary);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text-primary);
}
.cal-add-form input:focus, .cal-add-form select:focus { border-color: var(--mauve); box-shadow: 0 0 0 2px rgba(203,166,247,0.12); }
.cal-add-form input::placeholder { color: var(--text-muted); }
.cal-add-row { display: flex; gap: 6px; }
.cal-add-row input { flex: 1; }
.cal-add-btn {
  padding: 8px; background: var(--mauve); color: #1e1e2e; border-radius: 8px;
  font-size: 12px; font-weight: 600; transition: all 0.15s;
}
.cal-add-btn:hover { background: var(--accent); }
.cal-empty { text-align: center; color: var(--text-muted); font-size: 12px; padding: 20px 0; }
.cal-allday-bar { padding: 0 16px 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.cal-allday-chip {
  font-size: 11px; padding: 2px 8px; border-radius: 6px; color: #1e1e2e;
  font-weight: 600; display: flex; align-items: center; gap: 4px; max-width: 100%;
}
.cal-allday-chip button { color: rgba(0,0,0,0.5); font-size: 10px; padding: 0; }
.cal-allday-chip button:hover { color: #1e1e2e; }
.cal-day-events { display: flex; flex-direction: column; gap: 1px; width: 100%; margin-top: 1px; }
.cal-day-evt-chip { font-size: 8px; padding: 0 2px; border-radius: 2px; color: #1e1e2e; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.4; }

/* Timeline */
.cal-timeline-wrap { flex: 1; overflow-y: auto; position: relative; user-select: none; }
.cal-timeline { position: relative; min-height: calc(24 * 48px); }
.cal-tl-hour {
  height: 48px; border-bottom: 1px solid var(--border); display: flex; position: relative;
}
.cal-tl-label { width: 44px; font-size: 11px; color: var(--text-muted); text-align: right; padding: 0 6px; flex-shrink: 0; transform: translateY(-6px); }
.cal-tl-cell { flex: 1; position: relative; }
.cal-tl-cell:hover { background: rgba(137,180,250,0.04); }
.cal-tl-now {
  position: absolute; left: 44px; right: 0; height: 2px; background: var(--red); z-index: 5; pointer-events: none;
}
.cal-tl-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.cal-tl-event {
  position: absolute; left: 48px; right: 4px; border-radius: 6px; padding: 4px 8px;
  font-size: 11px; font-weight: 600; color: #1e1e2e; overflow: hidden; cursor: pointer; z-index: 3;
  display: flex; flex-direction: column; justify-content: flex-start; min-height: 20px;
}
.cal-tl-event:hover { filter: brightness(1.1); }
.cal-tl-event .ev-time { font-size: 9px; font-weight: 400; opacity: 0.7; }
.cal-tl-event .ev-del {
  position: absolute; top: 2px; right: 4px; font-size: 12px; opacity: 0; padding: 0 2px; color: rgba(0,0,0,0.5);
}
.cal-tl-event:hover .ev-del { opacity: 1; }
.cal-tl-drag {
  position: absolute; left: 48px; right: 4px; background: rgba(203,166,247,0.2);
  border: 1px dashed var(--mauve); border-radius: 6px; z-index: 2; pointer-events: none;
}
.cal-tl-drag.selected {
  background: rgba(203,166,247,0.3); border: 1px solid var(--mauve);
}
.cal-add-form .cal-checkbox { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }
.cal-add-form .cal-checkbox input[type="checkbox"] { accent-color: var(--mauve); width: 14px; height: 14px; cursor: pointer; }

/* ===== Drop Zone Overlay ===== */
.drop-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.drop-overlay-inner {
  border: 3px dashed var(--accent); border-radius: 20px; padding: 60px 80px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  background: var(--bg-secondary); box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}
.drop-overlay-inner svg { color: var(--accent); }
.drop-overlay-inner .drop-title { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.drop-overlay-inner .drop-sub { font-size: 14px; color: var(--text-secondary); }
.drop-count-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 10000;
  background: var(--green); color: #1e1e2e; padding: 10px 24px; border-radius: 10px;
  font-size: 14px; font-weight: 600; box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { position: fixed; z-index: 100; height: 100vh; }
  .sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-width)); }
  .folder-notes-panel { position: fixed; left: var(--sidebar-width); z-index: 99; height: 100vh; }
  .folder-notes-panel.collapsed { width: 0; min-width: 0; max-width: 0; }
  .content-area { padding: 20px 16px; }
}

/* Heatmap scroll - hidden scrollbar */
.heatmap-scroll { overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
.heatmap-scroll::-webkit-scrollbar { display: none; }

/* Activity heatmap - always-visible styled scrollbar */
.activity-heatmap-scroll { overflow-x: scroll; padding-bottom: 4px; scrollbar-width: thin; scrollbar-color: var(--text-muted) transparent; }
.activity-heatmap-scroll::-webkit-scrollbar { height: 8px; }
.activity-heatmap-scroll::-webkit-scrollbar-track { background: var(--bg-tertiary); border-radius: 4px; }
.activity-heatmap-scroll::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; min-width: 60px; }

/* ============================================================
 * Tamagotchi Panel — Hyowon's Archive themed
 * (Catppuccin Mocha 팔레트, 클린한 카드 스타일)
 * ============================================================ */
.tama-root { display: flex; flex-direction: column; padding: 14px 16px 18px; gap: 14px; }

.tama-device {
  position: relative;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 14px 16px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.25);
}

.tama-deco { display: flex; justify-content: center; gap: 8px; padding: 2px 0 8px; }
.tama-led {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px currentColor;
  animation: tama-led-pulse 2.2s ease-in-out infinite;
  color: var(--accent);
}
.tama-led:nth-child(2) { color: var(--mauve); background: var(--mauve); animation-delay: .2s; }
.tama-led:nth-child(3) { color: var(--green); background: var(--green); animation-delay: .4s; }
.tama-led:nth-child(4) { color: var(--peach); background: var(--peach); animation-delay: .6s; }
.tama-led:nth-child(5) { color: var(--yellow); background: var(--yellow); animation-delay: .8s; }
@keyframes tama-led-pulse {
  0%,100% { opacity: .45; transform: scale(0.9); }
  50%     { opacity: 1;   transform: scale(1.1); }
}

.tama-screen {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 0.92;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(137,180,250,0.10) 0%, transparent 65%),
    var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
:root.light .tama-screen {
  background:
    radial-gradient(ellipse at 50% 35%, rgba(30,102,245,0.08) 0%, transparent 65%),
    var(--bg-secondary);
}
.tama-grid-bg {
  position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background-image:
    linear-gradient(rgba(137,180,250,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(137,180,250,0.06) 1px, transparent 1px);
  background-size: 18px 18px;
}
.tama-view {
  position: relative; z-index: 2;
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 14px 12px; gap: 10px;
}
.tama-view[hidden] { display: none !important; }
/* 시작 화면 전용 — 알은 .tama-stage 로 중앙 정렬, 타이틀/서브타이틀만 직후에 */
.tama-view.is-intro {
  padding: 14px 12px 18px;
  gap: 4px;
  justify-content: flex-start;
}
.tama-view.is-intro .tama-stage {
  flex: 1 1 auto;
  min-height: 130px;
  margin-bottom: 2px;
}
.tama-view.is-intro .tama-title    { font-size: 14px; margin: 2px 0 0; }
.tama-view.is-intro .tama-subtitle { font-size: 11px; margin: 0; }

/* 시작 화면 폼 — 다마고치 장치 아래쪽, 화면(tama-screen) 바깥 */
.tama-intro-form {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
}
.tama-intro-form .tama-name-label { margin-top: 0; }
.tama-intro-form .tama-btn-primary { margin-top: 2px; }
.tama-intro-form .tama-hint { margin: 2px 0 0; }

/* 시작 화면 */
.tama-title {
  margin: 0; font-size: 14px; font-weight: 800;
  color: var(--accent); letter-spacing: 0.5px;
}
.tama-subtitle { margin: 0; font-size: 11px; color: var(--text-muted); }
.tama-name-label { display: block; font-size: 10px; color: var(--text-secondary); margin-top: 6px; }
.tama-input {
  width: 180px; padding: 8px 10px; font-size: 13px; text-align: center;
  color: var(--text-primary); background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: 8px;
  letter-spacing: 1px; transition: border-color 0.15s, box-shadow 0.15s;
}
.tama-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
.tama-btn-primary {
  margin-top: 4px; padding: 9px 18px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.5px;
  color: #1e1e2e; background: var(--accent);
  border-radius: 8px; cursor: pointer;
  transition: transform .1s, background .15s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(137,180,250,0.25);
}
.tama-btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 14px rgba(137,180,250,0.35); }
.tama-btn-primary:active { transform: translateY(1px); }
.tama-hint { margin: 4px 0 0; font-size: 10px; color: var(--text-muted); }

/* 알 (CSS 픽셀 아트) */
.tama-egg {
  width: 56px; height: 72px; position: relative;
  flex: 0 0 auto;   /* 부모 flex 컨테이너에서 쭈그러들지 않도록 고정 */
  background:
    radial-gradient(ellipse 65% 50% at 35% 32%, rgba(255,255,255,0.4) 0%, transparent 60%),
    linear-gradient(165deg, var(--mauve) 0%, var(--accent) 100%);
  border-radius: 50% 50% 48% 48% / 60% 60% 40% 40%;
  box-shadow:
    0 0 18px rgba(137,180,250,0.4),
    inset -4px -8px 12px rgba(0,0,0,0.25),
    inset 4px 4px 10px rgba(255,255,255,0.15);
  animation: tama-egg-wobble 2.4s ease-in-out infinite;
}
.tama-egg::before {
  content: ""; position: absolute; top: 45%; left: 12%; right: 12%; height: 3px;
  background: rgba(0,0,0,0.35);
  clip-path: polygon(0 50%, 8% 0, 16% 100%, 24% 0, 32% 100%, 40% 0, 48% 100%, 56% 0, 64% 100%, 72% 0, 80% 100%, 88% 0, 96% 100%, 100% 50%);
  opacity: 0; transition: opacity .4s;
}
.tama-egg.is-cracking::before { opacity: 1; }
.tama-egg-intro { width: 52px; height: 66px; margin-top: 2px; margin-bottom: 2px; }
@keyframes tama-egg-wobble {
  0%,100% { transform: rotate(-4deg); }
  50%     { transform: rotate(4deg); }
}
/* 크랙이 쌓일수록 흔들림이 강해지도록 data-crack 단계별 오버라이드 */
.tama-egg[data-crack="1"] { animation-duration: 1.8s; }
.tama-egg[data-crack="2"] { animation-duration: 1.2s; }
.tama-egg[data-crack="3"] {
  animation: tama-egg-shake 0.45s ease-in-out infinite;
  box-shadow:
    0 0 26px rgba(245,194,231,0.55),
    inset -4px -8px 12px rgba(0,0,0,0.25),
    inset 4px 4px 10px rgba(255,255,255,0.2);
}
@keyframes tama-egg-shake {
  0%,100% { transform: translate(0, 0) rotate(-5deg); }
  20%     { transform: translate(-1px, 0) rotate(4deg); }
  40%     { transform: translate(1px, 1px) rotate(-4deg); }
  60%     { transform: translate(-1px, -1px) rotate(5deg); }
  80%     { transform: translate(1px, 0) rotate(-3deg); }
}
@keyframes tama-hatch-pulse {
  0%,100% { transform: scale(1);    box-shadow: 0 0 10px rgba(245,194,231,0.35); }
  50%     { transform: scale(1.05); box-shadow: 0 0 18px rgba(245,194,231,0.6);  }
}

/* 스테이지 & 캐릭터 */
.tama-stage {
  position: relative; width: 100%; flex: 1;
  display: flex; align-items: center; justify-content: center;
  min-height: 120px;
}
.tama-char {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 4px 10px rgba(137,180,250,0.35));
  transition: filter .3s;
  animation: tama-bounce 1s ease-in-out infinite;
}
.tama-char.stage-egg   { width: 96px; }
.tama-char.stage-baby  { width: 84px; }
.tama-char.stage-adult { width: 118px; }
.tama-char.is-sleeping { animation: tama-breathe 2.2s ease-in-out infinite; filter: drop-shadow(0 4px 10px rgba(203,166,247,0.35)) brightness(0.75); }
.tama-char.is-sick     { animation: tama-sway 0.8s ease-in-out infinite; filter: drop-shadow(0 4px 10px rgba(243,139,168,0.35)) saturate(0.55); }
.tama-char.is-dead     { animation: none; filter: grayscale(1) opacity(0.55); }

/* ============== 액션 애니메이션 ============== */
/* 각 애니메이션은 1.5s 동안만 재생 (actionTimerRef 와 맞춤). */

/* ----- feed: 캐릭터가 그릇 쪽으로 살짝 숙였다 폈다 하며 먹는 모션 ----- */
.tama-char.is-action-feed {
  animation: tama-feed-chomp 0.45s ease-in-out 3;
}
@keyframes tama-feed-chomp {
  0%, 100% { transform: translateY(0)    rotate(0deg); }
  40%      { transform: translateY(2px)  rotate(-3deg); }
  70%      { transform: translateY(-1px) rotate(2deg);  }
}
.tama-anim-feed-bowl {
  transform-origin: center;
  animation: tama-feed-bowl-wobble 0.45s ease-in-out 3;
}
@keyframes tama-feed-bowl-wobble {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(1px) scale(0.97); }
}
.tama-anim-feed-steam {
  animation: tama-feed-steam 1.2s ease-out infinite;
  transform-origin: center;
}
@keyframes tama-feed-steam {
  0%   { transform: translateY(4px)  scaleY(0.6); opacity: 0; }
  40%  { opacity: 0.8; }
  100% { transform: translateY(-4px) scaleY(1);   opacity: 0; }
}

/* ----- play: 캐릭터가 위아래로 신나게 점프하며 공이 튐 ----- */
.tama-char.is-action-play {
  animation: tama-play-bounce 0.38s ease-in-out 4;
}
@keyframes tama-play-bounce {
  0%, 100% { transform: translateY(0)   rotate(0deg); }
  45%      { transform: translateY(-6px) rotate(-4deg); }
  55%      { transform: translateY(-6px) rotate(4deg);  }
}
.tama-anim-play-ball {
  transform-origin: center;
  animation: tama-play-ball 0.38s ease-in-out 4;
}
@keyframes tama-play-ball {
  0%, 100% { transform: translateY(0)   scaleX(1)    scaleY(1); }
  25%      { transform: translateY(-10px) scaleX(0.9) scaleY(1.1); }
  50%      { transform: translateY(0)   scaleX(1.1) scaleY(0.85); }
  75%      { transform: translateY(-6px)  scaleX(0.95) scaleY(1.05); }
}
.tama-anim-play-lines {
  animation: tama-play-lines 0.38s ease-out 4;
}
@keyframes tama-play-lines {
  0%   { opacity: 0; transform: translateX(0); }
  30%  { opacity: 0.8; }
  100% { opacity: 0; transform: translateX(4px); }
}

/* ----- shower: 물방울 낙하 + 거품 떠다님 ----- */
.tama-char.is-action-shower {
  animation: tama-shower-shiver 0.2s ease-in-out infinite;
}
@keyframes tama-shower-shiver {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(0.8px); }
}
.tama-anim-shower-drops .d {
  animation: tama-shower-drop 0.6s linear infinite;
  transform-origin: center;
}
.tama-anim-shower-drops .d1 { animation-delay: 0.00s; }
.tama-anim-shower-drops .d2 { animation-delay: 0.12s; }
.tama-anim-shower-drops .d3 { animation-delay: 0.24s; }
.tama-anim-shower-drops .d4 { animation-delay: 0.36s; }
.tama-anim-shower-drops .d5 { animation-delay: 0.48s; }
@keyframes tama-shower-drop {
  0%   { transform: translateY(0)    scaleY(0.6); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translateY(32px) scaleY(1.3); opacity: 0; }
}
.tama-anim-shower-bubbles .b {
  animation: tama-shower-bubble 1.4s ease-in-out infinite;
  transform-origin: center;
}
.tama-anim-shower-bubbles .b1 { animation-delay: 0.00s; }
.tama-anim-shower-bubbles .b2 { animation-delay: 0.30s; }
.tama-anim-shower-bubbles .b3 { animation-delay: 0.60s; }
.tama-anim-shower-bubbles .b4 { animation-delay: 0.90s; }
.tama-anim-shower-bubbles .b5 { animation-delay: 0.20s; }
@keyframes tama-shower-bubble {
  0%   { opacity: 0; transform: translateY(2px)  scale(0.6); }
  30%  { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(-8px) scale(1.15); }
}

/* ----- walk: 캐릭터가 좌우로 훨씬 더 멀리, 더 오래 걸어다님 ----- */
/* 전체 4초짜리 여정: 중앙 → 왼쪽 끝(-35px) → 중앙 → 오른쪽 끝(+35px) → 중앙 */
.tama-char.is-action-walk {
  animation: tama-walk-step 4s ease-in-out 1;
}
@keyframes tama-walk-step {
  0%   { transform: translateX(0)    rotate(0deg); }
  8%   { transform: translateX(-10px) rotate(-3deg); }
  18%  { transform: translateX(-22px) rotate(-5deg); }
  30%  { transform: translateX(-35px) rotate(-6deg); }
  40%  { transform: translateX(-22px) rotate(-4deg); }
  50%  { transform: translateX(0)    rotate(0deg); }
  58%  { transform: translateX(12px) rotate(3deg); }
  68%  { transform: translateX(24px) rotate(5deg); }
  80%  { transform: translateX(35px) rotate(6deg); }
  90%  { transform: translateX(18px) rotate(3deg); }
  100% { transform: translateX(0)    rotate(0deg); }
}
/* 발자국 — 캐릭터의 이동 경로를 따라 시차를 두고 나타남.
   delay 는 CSS 키프레임의 각 퍼센트 시점(전체 4s) 과 맞춘다. */
.tama-anim-walk .fp {
  animation: tama-walk-fp 4s ease-out 1;
  transform-origin: center;
  opacity: 0;
}
.tama-anim-walk .fp1 { animation-delay: 0.30s; } /* 왼쪽 -6  */
.tama-anim-walk .fp2 { animation-delay: 0.75s; } /* 왼쪽 -16 */
.tama-anim-walk .fp3 { animation-delay: 1.15s; } /* 왼쪽 -26 */
.tama-anim-walk .fp4 { animation-delay: 1.55s; } /* 왼쪽 -34 */
.tama-anim-walk .fp5 { animation-delay: 2.30s; } /* 오른쪽 +6  */
.tama-anim-walk .fp6 { animation-delay: 2.70s; } /* 오른쪽 +16 */
.tama-anim-walk .fp7 { animation-delay: 3.10s; } /* 오른쪽 +26 */
.tama-anim-walk .fp8 { animation-delay: 3.45s; } /* 오른쪽 +34 */
@keyframes tama-walk-fp {
  0%   { opacity: 0;    transform: scale(0.4); }
  2%   { opacity: 0.85; transform: scale(1); }
  40%  { opacity: 0.85; transform: scale(1); }
  100% { opacity: 0;    transform: scale(1); }
}

/* 스프라이트시트 애니메이션(신규): baby 4프레임 상태들 */
.tama-char-anim {
  display: inline-block;
  line-height: 0;
}
.tama-char-anim.stage-baby  { width: 96px; height: 96px; }
.tama-char-anim.stage-adult { width: 128px; height: 128px; }
.tama-char-sprite {
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-size: 384px 96px;   /* 96x96 원본 4프레임, 1:1 렌더 */
  background-position: 0 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
/* 기본 재생 키프레임: 4프레임 순환. step당 -96px씩 이동 */
@keyframes tama-sprite-play {
  from { background-position-x: 0; }
  to   { background-position-x: -384px; }
}
.tama-char-anim.stage-baby .tama-char-sprite[data-sprite="baby_idle"] {
  background-image: url("./sprites/baby_idle_4.png");
  animation: tama-sprite-play 0.9s steps(4) infinite;
}
.tama-char-anim.stage-baby .tama-char-sprite[data-sprite="baby_happy"] {
  background-image: url("./sprites/baby_happy_4.png");
  animation: tama-sprite-play 0.55s steps(4) infinite;
}
.tama-char-anim.stage-baby .tama-char-sprite[data-sprite="baby_eating"] {
  background-image: url("./sprites/baby_eating_4.png");
  animation: tama-sprite-play 0.5s steps(4) infinite;
}
.tama-char-anim.stage-baby .tama-char-sprite[data-sprite="baby_sleeping"] {
  background-image: url("./sprites/baby_sleeping_4.png");
  animation: tama-sprite-play 1.6s steps(4) infinite;
}
.tama-char-anim.stage-baby .tama-char-sprite[data-sprite="baby_sick"] {
  background-image: url("./sprites/baby_sick_4.png");
  animation: tama-sprite-play 0.7s steps(4) infinite;
}

@keyframes tama-bounce  { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes tama-breathe { 0%,100% { transform: scaleY(1); } 50% { transform: scaleY(0.96); } }
@keyframes tama-sway    { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }

.tama-fx {
  position: absolute; font-size: 22px; pointer-events: none;
  animation: tama-fx-float 1.2s ease-out forwards;
  color: var(--mauve);
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
  z-index: 5;
}
@keyframes tama-fx-float {
  0%   { opacity: 0; transform: translateY(0) scale(0.5); }
  20%  { opacity: 1; transform: translateY(-8px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-60px) scale(1); }
}
.tama-poop {
  position: absolute; bottom: 8px; font-size: 18px;
  animation: tama-bounce 1.4s ease-in-out infinite;
}
.tama-poop:nth-child(1) { right: 18%; }
.tama-poop:nth-child(2) { right: 30%; animation-delay: .2s; }
.tama-poop:nth-child(3) { right: 42%; animation-delay: .4s; }

/* 상태 바 */
.tama-stats {
  width: 100%; display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 6px 10px; padding: 6px 6px 2px;
}
.tama-stat { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--text-secondary); }
.tama-stat-ico { width: 12px; text-align: center; font-size: 11px; }
.tama-stat[data-stat="love"]    .tama-stat-ico { color: var(--red); }
.tama-stat[data-stat="hunger"]  .tama-stat-ico { color: var(--peach); }
.tama-stat[data-stat="comfort"] .tama-stat-ico { color: var(--accent); }
.tama-stat[data-stat="energy"]  .tama-stat-ico { color: var(--green); }
.tama-stat-bar {
  flex: 1; height: 6px; background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: 4px; overflow: hidden;
}
.tama-stat-fill { height: 100%; width: 80%; background: currentColor; color: var(--accent); transition: width 0.4s ease, color 0.3s; }
.tama-stat[data-stat="love"]    .tama-stat-fill { color: var(--red); }
.tama-stat[data-stat="hunger"]  .tama-stat-fill { color: var(--peach); }
.tama-stat[data-stat="comfort"] .tama-stat-fill { color: var(--accent); }
.tama-stat[data-stat="energy"]  .tama-stat-fill { color: var(--green); }
.tama-stat.is-low .tama-stat-fill { color: var(--red) !important; animation: tama-blink 0.8s infinite; }
@keyframes tama-blink { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* 이름바 */
.tama-namebar {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 11px; color: var(--text-primary);
}
.tama-stage-badge {
  font-size: 9px; padding: 2px 7px; border-radius: 10px;
  background: var(--accent-dim); color: var(--accent);
  border: 1px solid var(--accent); font-weight: 700; letter-spacing: 0.5px;
}
.tama-stage-badge[data-stage="BABY"]  { color: var(--green); border-color: var(--green); background: rgba(166,227,161,0.12); }
.tama-stage-badge[data-stage="ADULT"] { color: var(--mauve); border-color: var(--mauve); background: rgba(203,166,247,0.12); }
.tama-petname { font-size: 13px; font-weight: 700; }
.tama-age { font-size: 10px; color: var(--text-muted); }

/* 사망 화면 */
.tama-dead-icon { font-size: 48px; color: var(--text-muted); }
.tama-dead-text { font-size: 12px; color: var(--text-secondary); margin: 0; }

/* 버튼 패드 — aspect-ratio 4:1 로 폭과 무관하게 항상 같은 높이 예약 */
.tama-pad {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  aspect-ratio: 4 / 1;
}
.tama-action {
  position: relative;
  aspect-ratio: 1 / 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  padding: 6px 2px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer; transition: all 0.15s;
}
.tama-action:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}
.tama-action:active:not(:disabled) { transform: translateY(1px); }
.tama-action:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  /* 비활성 상태에서도 호버 툴팁은 뜨게 */
  pointer-events: auto;
}
.tama-action-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
  color: inherit;
}
.tama-action-ico svg { width: 18px; height: 18px; }
.tama-action-label { font-size: 9px; font-weight: 600; letter-spacing: 0.2px; }

/* 액션 버튼 툴팁 — 게이지 설명이 길어질 수 있어 줄바꿈 허용 + 고정 폭 */
.tama-action[data-tama-tooltip]::after {
  white-space: normal;
  width: max-content;
  max-width: 180px;
  text-align: center;
  font-size: 10px;
  line-height: 1.4;
  padding: 6px 9px;
  word-break: keep-all;
  overflow-wrap: break-word;
}
/* 맨 왼쪽/오른쪽 버튼은 기본 중앙 정렬이면 화면 밖으로 삐져나갈 수 있으니,
   grid 셀 인덱스로 앵커를 좌/우에 붙여준다. */
.tama-pad .tama-action:nth-child(4n + 1)[data-tama-tooltip]::after {
  left: 0;
  transform: translateX(0) translateY(4px);
}
.tama-pad .tama-action:nth-child(4n + 1)[data-tama-tooltip]:hover::after,
.tama-pad .tama-action:nth-child(4n + 1)[data-tama-tooltip]:focus-visible::after {
  transform: translateX(0) translateY(0);
}
.tama-pad .tama-action:nth-child(4n)[data-tama-tooltip]::after {
  left: auto; right: 0;
  transform: translateX(0) translateY(4px);
}
.tama-pad .tama-action:nth-child(4n)[data-tama-tooltip]:hover::after,
.tama-pad .tama-action:nth-child(4n)[data-tama-tooltip]:focus-visible::after {
  transform: translateX(0) translateY(0);
}

/* 토스트 */
.tama-toasts {
  position: absolute; top: 12px; left: 12px; right: 12px;
  display: flex; flex-direction: column; gap: 6px;
  z-index: 10; pointer-events: none;
}
.tama-toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px; font-size: 11px; font-weight: 600;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  animation: tama-toast-in .25s ease-out, tama-toast-out .25s ease-in 2.4s forwards;
}
.tama-toast.is-error { border-color: var(--red); color: var(--red); }
.tama-toast.is-ok    { border-color: var(--green); color: var(--green); }
@keyframes tama-toast-in  { from { transform: translateY(-6px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes tama-toast-out { to   { transform: translateY(-6px); opacity: 0; } }
.activity-heatmap-scroll::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ===== Tamagotchi 스타일 툴팁 ===== */
/* data-tama-tooltip 속성만 달면 테마에 맞는 툴팁이 호버 시 나타남.
   ::after 는 버튼 위쪽에 떠오르고, 버튼이 disabled 여도 보인다. */
[data-tama-tooltip] { position: relative; }
[data-tama-tooltip]::after {
  content: attr(data-tama-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%) translateY(4px);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 100;
}
[data-tama-tooltip]::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 1px);
  transform: translateX(-50%) translateY(4px);
  border: 5px solid transparent;
  border-top-color: var(--border);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 100;
}
[data-tama-tooltip]:hover::after,
[data-tama-tooltip]:hover::before,
[data-tama-tooltip]:focus-visible::after,
[data-tama-tooltip]:focus-visible::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
/* 바닥에 붙은 행의 버튼들은 위로 뜰 공간이 없어서 아래에 띄운다 */
[data-tama-tooltip][data-tama-tooltip-place="bottom"]::after {
  top: calc(100% + 6px);
  bottom: auto;
}
[data-tama-tooltip][data-tama-tooltip-place="bottom"]::before {
  top: calc(100% + 1px);
  bottom: auto;
  border-top-color: transparent;
  border-bottom-color: var(--border);
}

/* 게이지 툴팁 — 긴 설명이 들어가므로 줄바꿈 허용 + 고정 폭.
   tama-screen 을 넘지 않도록 max-width 로 제한.
   한국어는 word-break: keep-all 로 어절 단위로 끊어주고,
   오른쪽 컬럼(hunger/energy) 은 오른쪽 모서리에 앵커해서 바깥으로 삐져나가지 않게 함. */
.tama-stat[data-tama-tooltip]::after {
  white-space: normal;
  width: max-content;
  max-width: 160px;
  text-align: center;
  font-size: 10px;
  line-height: 1.4;
  padding: 6px 9px;
  word-break: keep-all;
  overflow-wrap: break-word;
}
/* 오른쪽 컬럼 — 툴팁이 왼쪽으로 펼쳐지도록 앵커 변경 */
.tama-stat[data-stat="hunger"][data-tama-tooltip]::after,
.tama-stat[data-stat="energy"][data-tama-tooltip]::after {
  left: auto;
  right: 0;
  transform: translateX(0) translateY(4px);
}
.tama-stat[data-stat="hunger"][data-tama-tooltip]:hover::after,
.tama-stat[data-stat="energy"][data-tama-tooltip]:hover::after,
.tama-stat[data-stat="hunger"][data-tama-tooltip]:focus-visible::after,
.tama-stat[data-stat="energy"][data-tama-tooltip]:focus-visible::after {
  transform: translateX(0) translateY(0);
}
/* 화살표(::before) 도 오른쪽 컬럼에선 오른쪽 가까이로 이동 */
.tama-stat[data-stat="hunger"][data-tama-tooltip]::before,
.tama-stat[data-stat="energy"][data-tama-tooltip]::before {
  left: auto;
  right: 14px;
  transform: translateX(0) translateY(4px);
}
.tama-stat[data-stat="hunger"][data-tama-tooltip]:hover::before,
.tama-stat[data-stat="energy"][data-tama-tooltip]:hover::before,
.tama-stat[data-stat="hunger"][data-tama-tooltip]:focus-visible::before,
.tama-stat[data-stat="energy"][data-tama-tooltip]:focus-visible::before {
  transform: translateX(0) translateY(0);
}
/* 왼쪽 컬럼 — 화살표를 왼쪽 가까이로 (기본 left:50% 는 가운데라 밀려보임) */
.tama-stat[data-stat="love"][data-tama-tooltip]::after,
.tama-stat[data-stat="comfort"][data-tama-tooltip]::after {
  left: 0;
  transform: translateX(0) translateY(4px);
}
.tama-stat[data-stat="love"][data-tama-tooltip]:hover::after,
.tama-stat[data-stat="comfort"][data-tama-tooltip]:hover::after,
.tama-stat[data-stat="love"][data-tama-tooltip]:focus-visible::after,
.tama-stat[data-stat="comfort"][data-tama-tooltip]:focus-visible::after {
  transform: translateX(0) translateY(0);
}
.tama-stat[data-stat="love"][data-tama-tooltip]::before,
.tama-stat[data-stat="comfort"][data-tama-tooltip]::before {
  left: 14px;
  transform: translateX(0) translateY(4px);
}
.tama-stat[data-stat="love"][data-tama-tooltip]:hover::before,
.tama-stat[data-stat="comfort"][data-tama-tooltip]:hover::before,
.tama-stat[data-stat="love"][data-tama-tooltip]:focus-visible::before,
.tama-stat[data-stat="comfort"][data-tama-tooltip]:focus-visible::before {
  transform: translateX(0) translateY(0);
}

/* ============================================================
   미니게임: 캐릭터 말풍선 퀴즈
   tama-screen 최상위에 absolute 로 얹어서 overflow:hidden 으로 잘리지 않게 함.
   화면 상단 ~ 캐릭터 위까지 공간을 차지하고, 꼬리는 아래쪽(캐릭터) 을 가리킨다.
   ============================================================ */
.tama-quiz-bubble {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  /* 캐릭터 공간은 아래쪽 약간만 남기고, 말풍선이 화면 대부분을 차지 */
  max-height: calc(100% - 112px);
  display: flex;
  flex-direction: column;
  background: var(--bg-primary, #1e1e2e);
  border: 1.5px solid var(--accent, #89b4fa);
  border-radius: 14px;
  padding: 12px 14px 14px;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.45),
    0 0 16px rgba(137, 180, 250, 0.25);
  color: var(--text-primary, #cdd6f4);
  font-size: 13px;
  line-height: 1.5;
  z-index: 40;
  animation: tama-quiz-pop 0.22s cubic-bezier(0.2, 1.2, 0.4, 1);
  overflow: hidden;
}
:root.light .tama-quiz-bubble {
  background: var(--bg-primary, #eff1f5);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.18),
    0 0 16px rgba(30, 102, 245, 0.18);
}
@keyframes tama-quiz-pop {
  0%   { opacity: 0; transform: translateY(-6px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0)    scale(1); }
}

/* 말풍선 꼬리 — 캐릭터 쪽(아래) 을 가리키는 삼각형 */
.tama-quiz-bubble-tail {
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 14px;
  height: 14px;
  transform: translateX(-50%) rotate(45deg);
  background: var(--bg-primary, #1e1e2e);
  border-right: 1.5px solid var(--accent, #89b4fa);
  border-bottom: 1.5px solid var(--accent, #89b4fa);
  border-bottom-right-radius: 3px;
  z-index: 1;
}
:root.light .tama-quiz-bubble-tail {
  background: var(--bg-primary, #eff1f5);
}

.tama-quiz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border, #313244);
  flex: 0 0 auto;
}
.tama-quiz-speaker {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent, #89b4fa);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: calc(100% - 22px);
}
.tama-quiz-speaker-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent, #89b4fa);
  box-shadow: 0 0 6px rgba(137, 180, 250, 0.7);
  flex: 0 0 auto;
}
.tama-quiz-note {
  color: var(--text-muted, #6c7086);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 2px;
}
.tama-quiz-close {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border, #313244);
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted, #6c7086);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tama-quiz-close:hover {
  color: #f38ba8;
  border-color: #f38ba8;
  background: rgba(243, 139, 168, 0.08);
}

.tama-quiz-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}
.tama-quiz-body::-webkit-scrollbar { width: 6px; }
.tama-quiz-body::-webkit-scrollbar-thumb {
  background: var(--border, #313244);
  border-radius: 3px;
}
.tama-quiz-loading {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text-muted, #6c7086);
  font-style: italic;
  padding: 4px 2px;
}
.tama-quiz-dot-anim {
  display: inline-flex;
  gap: 3px;
}
.tama-quiz-dot-anim span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent, #89b4fa);
  animation: tama-quiz-bounce 1s ease-in-out infinite;
}
.tama-quiz-dot-anim span:nth-child(2) { animation-delay: 0.15s; }
.tama-quiz-dot-anim span:nth-child(3) { animation-delay: 0.3s; }
@keyframes tama-quiz-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40%           { transform: scale(1);   opacity: 1;   }
}

.tama-quiz-question {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary, #cdd6f4);
  line-height: 1.55;
  word-break: keep-all;
  white-space: pre-wrap;
}
.tama-quiz-hint {
  font-size: 10.5px;
  color: var(--text-muted, #6c7086);
  background: rgba(249, 226, 175, 0.08);
  border-left: 2px solid #f9e2af;
  padding: 4px 6px;
  border-radius: 4px;
}
.tama-quiz-input {
  width: 100%;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.5;
  color: var(--text-primary, #cdd6f4);
  background: var(--bg-secondary, #181825);
  border: 1px solid var(--border, #313244);
  border-radius: 8px;
  resize: vertical;
  min-height: 64px;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.tama-quiz-input:focus {
  outline: none;
  border-color: var(--accent, #89b4fa);
  box-shadow: 0 0 0 2px rgba(137, 180, 250, 0.18);
}
.tama-quiz-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.tama-quiz-error {
  font-size: 10.5px;
  color: #f38ba8;
  padding: 2px 0;
}

.tama-quiz-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 2px;
}
.tama-quiz-btn {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  border-radius: 999px;
  border: 1px solid var(--border, #313244);
  background: transparent;
  color: var(--text-secondary, #a6adc8);
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, color 0.15s, border-color 0.15s;
}
.tama-quiz-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary, #cdd6f4);
}
.tama-quiz-btn:active:not(:disabled) { transform: translateY(1px); }
.tama-quiz-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.tama-quiz-btn.primary {
  background: var(--accent, #89b4fa);
  border-color: var(--accent, #89b4fa);
  color: #1e1e2e;
  box-shadow: 0 2px 8px rgba(137, 180, 250, 0.25);
}
.tama-quiz-btn.primary:hover:not(:disabled) {
  background: var(--accent-hover, #74c7ec);
  color: #1e1e2e;
}
.tama-quiz-btn.secondary {
  color: var(--text-muted, #6c7086);
}

.tama-quiz-verdict {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-align: center;
  padding: 4px 0 2px;
}
.tama-quiz-verdict.is-correct { color: #a6e3a1; text-shadow: 0 0 12px rgba(166,227,161,0.4); }
.tama-quiz-verdict.is-wrong   { color: #f38ba8; text-shadow: 0 0 12px rgba(243,139,168,0.35); }

.tama-quiz-feedback {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-primary, #cdd6f4);
  background: var(--bg-secondary, #181825);
  border: 1px solid var(--border, #313244);
  border-radius: 8px;
  padding: 7px 9px;
  word-break: keep-all;
  white-space: pre-wrap;
}
.tama-quiz-correct-answer {
  font-size: 10.5px;
  color: var(--text-secondary, #a6adc8);
  padding: 0 2px;
}
.tama-quiz-correct-label {
  font-weight: 700;
  color: #a6e3a1;
  margin-right: 4px;
}

/* tama-stage 내 퀴즈 말풍선이 뜰 때는 캐릭터 위에 제대로 얹히도록 stage 를
   relative 로 유지 (이미 그렇지만 방어적으로 재확인) */
.tama-stage { position: relative; }
