/* BuJo Mini-Emacs — sanityinc-tomorrow-eighties theme (from .emacs) */

:root {
  --bg:         #2d2d2d;
  --fg:         #cccccc;
  --bg-alt:     #393939;
  --bg-sel:     #515151;
  --comment:    #999999;
  --red:        #f2777a;
  --orange:     #f99157;
  --yellow:     #ffcc66;
  --green:      #99cc99;
  --cyan:       #66cccc;
  --blue:       #6699cc;
  --purple:     #cc99cc;
  --mantle:     #262626;
  --surface2:   #555555;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "SF Mono", "Menlo", "Consolas", "Liberation Mono", monospace;
  font-size: 14px;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* Editor area (Emacs iframe) */
#editor-wrap {
  flex: 1;
  border: none;
  width: 100%;
}

/* View bar */
#view-bar {
  display: flex;
  gap: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--bg-alt);
  flex-shrink: 0;
  padding: 0 4px;
}

.view-tab {
  background: transparent;
  border: none;
  color: var(--comment);
  font-family: inherit;
  font-size: 13px;
  padding: 4px 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.view-tab:hover { color: var(--fg); }
.view-tab.active { color: var(--yellow); border-bottom-color: var(--yellow); }

#download-btn {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--comment);
  font-family: inherit;
  font-size: 13px;
  padding: 4px 12px;
  cursor: pointer;
}
#download-btn:hover { color: var(--fg); }

/* View panels */
.view-panel { display: none; flex: 1; overflow: auto; padding: 0; }
.view-panel.active { display: flex; flex-direction: column; }
#editor-wrap.active { display: block; }

/* ── Daily view (3-day) ── */
.daily-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--bg-alt);
  flex-shrink: 0;
}

.daily-nav-btn {
  background: var(--bg-alt);
  border: 1px solid var(--bg-sel);
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  padding: 2px 10px;
  cursor: pointer;
  border-radius: 3px;
}

.daily-nav-btn:hover { background: var(--bg-sel); color: var(--yellow); }
.daily-nav-label { color: var(--comment); font-size: 13px; }

.daily-grid {
  display: flex;
  flex: 1;
  gap: 1px;
  background: var(--bg-alt);
}

.daily-col {
  flex: 1;
  background: var(--bg);
  padding: 12px;
  display: flex;
  flex-direction: column;
}

.daily-col.today { background: var(--mantle); }

.daily-header {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bg-alt);
}

.daily-date { color: var(--purple); font-weight: bold; font-size: 15px; }
.daily-label { color: var(--comment); font-size: 12px; }

.daily-items { display: flex; flex-direction: column; gap: 6px; }

/* ── View items (shared) ── */
.view-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1.5;
}

.bujo-sym { font-weight: bold; flex-shrink: 0; width: 14px; text-align: center; }
.bujo-sym.todo         { color: var(--red); }
.bujo-sym.migrated     { color: var(--purple); }
.bujo-sym.done         { color: var(--green); }
.bujo-sym.cancelled    { color: var(--comment); }
.bujo-sym.meeting      { color: var(--cyan); }
.bujo-sym.note         { color: var(--comment); }

.item-time { color: var(--cyan); font-size: 12px; flex-shrink: 0; }
.item-title { color: var(--fg); }
.view-item.todo .item-title { color: var(--red); }
.view-item.migrated .item-title { color: var(--purple); }
.view-item.done .item-title { color: var(--green); text-decoration: none; }
.view-item.cancelled .item-title { color: var(--comment); text-decoration: line-through; }
.view-item.meeting .item-title { color: var(--cyan); }
.item-tag {
  color: var(--blue);
  font-size: 11px;
  padding: 0 4px;
  background: rgba(102, 153, 204, 0.1);
  border-radius: 2px;
}

.item-link {
  color: var(--blue);
  font-size: 11px;
  text-decoration: none;
  padding: 0 5px;
  border: 1px solid var(--blue);
  border-radius: 3px;
  margin-left: 4px;
}
.item-link:hover { background: var(--blue); color: var(--bg); }

.empty { color: var(--comment); font-style: italic; font-size: 12px; }

/* ── Monthly view ── */
.month-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.month-list {
  padding: 12px 16px;
  flex: 1;
  overflow-y: auto;
}

.month-sidebar {
  flex: 1;
  overflow-y: auto;
  border-left: 1px solid var(--bg-alt);
  padding: 12px 16px;
}

.month-sidebar, .month-list {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.month-title {
  color: var(--purple);
  font-weight: bold;
  font-size: 16px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bg-alt);
}

.month-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.month-row.today { background: var(--mantle); }
.month-row.weekend .month-day-num { color: var(--comment); }

.month-day-num {
  color: var(--yellow);
  font-weight: bold;
  width: 24px;
  text-align: right;
  flex-shrink: 0;
}

.month-day-dow {
  color: var(--comment);
  width: 20px;
  flex-shrink: 0;
  font-size: 12px;
}

.month-day-summary {
  color: var(--fg);
  flex: 1;
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}

.month-day-summary .meeting-count { color: var(--cyan); font-size: 12px; }
.month-day-summary .task-count { color: var(--comment); font-size: 12px; }
.month-day-summary .task-count.todo { color: var(--red); }
.month-day-summary .task-count.migrated { color: var(--purple); }
.month-day-summary .task-count.done { color: var(--green); }
.month-day-summary .task-count.cancelled { color: var(--comment); }
.month-day-summary .task-count.meeting { color: var(--cyan); }
.month-day-summary .highlight { color: var(--fg); }

/* ── Monthly: weeks + goals sections ── */
.sidebar-area { margin-bottom: 16px; }
.sidebar-area-name { color: var(--yellow); font-weight: bold; margin-bottom: 6px; }
.sidebar-goal {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 0;
  line-height: 1.5;
}
.sidebar-goal.todo { color: var(--red); }
.sidebar-goal.done { color: var(--green); }
.sidebar-goal.migrated { color: var(--purple); }
.sidebar-goal.cancelled { color: var(--comment); }

.section-title {
  color: var(--yellow);
  font-weight: bold;
  margin-bottom: 8px;
}

.week-block { margin-bottom: 10px; }

/* ── Yearly view (goals) ── */
.yearly-title {
  color: var(--purple);
  font-weight: bold;
  font-size: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--bg-alt);
}

.yearly-month {
  padding: 10px 16px;
  border-bottom: 1px solid var(--bg-alt);
}
.yearly-month.current { background: var(--mantle); }
.yearly-month.empty-past { opacity: 0.5; }

.yearly-month-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.yearly-month-name { color: var(--purple); font-weight: bold; font-size: 14px; }
.yearly-month-badge {
  color: var(--bg);
  background: var(--purple);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: bold;
}

.yearly-month-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 13px;
}

.yearly-month-goals { margin-top: 4px; }

.yearly-area { padding: 12px 16px; }
.area-name { color: var(--yellow); font-weight: bold; margin-bottom: 8px; }


/* Modeline — Emacs style */
#modeline {
  display: flex;
  gap: 1em;
  padding: 2px 8px;
  background: var(--bg-alt);
  color: var(--fg);
  border-top: 1px solid var(--surface2);
  font-size: 13px;
  line-height: 1.6;
  flex-shrink: 0;
  user-select: none;
}

#ml-modified { color: var(--comment); }
#ml-buffer   { color: var(--yellow); font-weight: bold; }
#ml-pos      { color: var(--comment); }
#ml-mode     { color: var(--comment); margin-left: auto; }

/* Minibuffer */
#minibuffer {
  display: flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--bg);
  border-top: 1px solid var(--bg-alt);
  font-size: 13px;
  line-height: 1.6;
  flex-shrink: 0;
  position: relative;
  min-height: 24px;
}

#mb-prompt {
  color: var(--comment);
  margin-right: 4px;
  white-space: nowrap;
}

#mb-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font-family: inherit;
  font-size: inherit;
  caret-color: red;
  display: none;
}

#mb-input.active { display: block; }

#mb-completions {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--bg-alt);
  border: 1px solid var(--surface2);
  max-height: 200px;
  overflow-y: auto;
}

#mb-completions.active { display: block; }

#mb-completions .mb-item {
  padding: 2px 8px;
  cursor: pointer;
  color: var(--fg);
}

#mb-completions .mb-item.selected {
  background: var(--bg-sel);
  color: var(--yellow);
}

#mb-completions .mb-item:hover {
  background: var(--bg-sel);
}
