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

:root {
  --bg: #111;
  --bg-hover: #1a1a1a;
  --text: #ccc;
  --text-dim: #666;
  --accent: #D35400;
  --accent-dim: #a04000;
  --border: #222;
  --success: #27ae60;
  --error: #c0392b;
}

html, body {
  height: 100%;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* --- Header --- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: #0a0a0a;
}

header h1 {
  font-size: 15px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 2px;
}

#header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

#clock {
  color: var(--text-dim);
  font-size: 12px;
}

#mode-toggle, #install-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
}

#mode-toggle:hover, #install-btn:hover { border-color: var(--accent); color: var(--text); }

/* --- Dashboard --- */
#dashboard {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

/* Status row — horizontal chips */
#status-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.chip {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 3px;
  background: #1a1a1a;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.chip.stale {
  opacity: 0.4;
  color: var(--text-dim);
}

.chip.stale::after {
  content: '';
}

/* Sections */
.section {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.section:last-child { border-bottom: none; }

.section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent);
  margin-bottom: 4px;
  font-weight: 600;
}

.dim { color: var(--text-dim); font-style: italic; }

/* --- Weather (inline) --- */
#weather-inline {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  padding: 4px 0;
}

.wx-temp {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.wx-cond { color: var(--text); }
.wx-detail { color: var(--text-dim); font-size: 12px; }

/* --- Schedule --- */
.event {
  display: flex;
  align-items: baseline;
  padding: 3px 0;
  gap: 8px;
  font-size: 13px;
}

.event .time {
  color: var(--accent);
  min-width: 110px;
  font-size: 12px;
  flex-shrink: 0;
}

.event .summary { flex: 1; color: var(--text); }
.event .cal { color: var(--text-dim); font-size: 11px; }

.event-now {
  background: rgba(211, 84, 0, 0.1);
  border-radius: 3px;
  padding: 3px 4px;
  margin: 0 -4px;
}

/* --- Habits (inline) --- */
.habit {
  display: inline-flex;
  align-items: center;
  padding: 2px 0;
  margin-right: 12px;
  font-size: 13px;
}

.habit-icon {
  width: 16px;
  text-align: center;
  margin-right: 4px;
}

.habit.verified .habit-icon { color: var(--success); }
.habit.failed .habit-icon { color: var(--error); }
.habit.pending .habit-icon { color: var(--text-dim); }

.habit-name { color: var(--text); }

.habit-streak {
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
}

/* --- Chat --- */
#chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: 1px solid var(--accent);
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.msg {
  max-width: 88%;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.msg.user {
  align-self: flex-end;
  background: var(--accent-dim);
  color: #fff;
}

.msg.assistant {
  align-self: flex-start;
  background: #1a1a1a;
  border: 1px solid var(--border);
}

#chat-input-row {
  display: flex;
  padding: 8px 12px;
  gap: 6px;
  border-top: 1px solid var(--border);
}

#chat-input {
  flex: 1;
  background: #1a1a1a;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
  resize: none;
  outline: none;
}

#chat-input:focus { border-color: var(--accent); }

#chat-send {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
}

#chat-send:hover { background: var(--accent-dim); }
#chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Layout --- */
#main-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 38px);
  overflow: hidden;
}

#left-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
}

#right-panel {
  display: none;
  flex-direction: column;
}

/* HAL widget — top-right, sandboxed */
#widget-area {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

#widget-iframe {
  width: 100%;
  height: 180px;
  border: none;
  background: var(--bg);
}

#terminal-frame { width: 100%; flex: 1; }
#terminal-frame iframe { width: 100%; height: 100%; border: none; }

body.mode-terminal #left-panel { display: none; }
body.mode-terminal #right-panel { display: flex; flex: 1; }

@media (min-width: 769px) {
  #main-layout { flex-direction: row; }

  #left-panel {
    width: 38%;
    min-width: 300px;
    border-right: 1px solid var(--border);
  }

  #right-panel { display: flex; flex-direction: column; flex: 1; }

  body.mode-terminal #left-panel { display: none; }
  body.mode-terminal #right-panel { flex: 1; width: 100%; }
  body:not(.mode-terminal) #right-panel { display: flex; flex-direction: column; }
}

.stale { opacity: 0.4; }
