:root {
  --bg: #ffffff;
  --bg-subtle: #f8f8f8;
  --border: #e6e6e6;
  --border-hover: #cccccc;
  --text: #0f0f0f;
  --text-muted: #666666;
  --text-subtle: #999999;
  
  --btn-bg: #0f0f0f;
  --btn-text: #ffffff;
  --btn-outline-border: #d0d0d0;
  
  --dot-color: #10b981;
  --checkbox-border: #a0a0a0;
  --checkbox-checked: #0f0f0f;
  --checkbox-tick: #ffffff;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-subtle: #0d0d0d;
    --border: #1a1a1a;
    --border-hover: #333333;
    --text: #f5f5f5;
    --text-muted: #888888;
    --text-subtle: #555555;

    --btn-bg: #ffffff;
    --btn-text: #000000;
    --btn-outline-border: #2a2a2a;

    --dot-color: #34d399;
    --checkbox-border: #444444;
    --checkbox-checked: #ffffff;
    --checkbox-tick: #000000;
  }
}

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

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand h1 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dot-color);
  display: inline-block;
}

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

/* Minimal Buttons */
.btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.btn:active {
  opacity: 0.7;
}

.btn-primary {
  background: var(--btn-bg);
  color: var(--btn-text);
  border-color: var(--btn-bg);
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-outline {
  border-color: var(--btn-outline-border);
}

.btn-outline:hover {
  border-color: var(--border-hover);
  background: var(--bg-subtle);
}

.btn-ghost {
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text);
}

.btn-icon {
  padding: 6px 8px;
  color: var(--text-subtle);
}

.btn-icon:hover {
  color: var(--text);
}

/* Running Banner */
.running-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 20px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text);
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.2; }
  to { opacity: 1; }
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 20px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.tab-btn {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
  cursor: pointer;
  padding-bottom: 8px;
  position: relative;
  transition: color 0.15s ease;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--text);
  font-weight: 600;
}

.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: -9px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--text);
}

/* Tab Panes */
.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Document View */
.doc-container {
  padding: 8px 0;
}

.doc-meta {
  font-size: 12px;
  color: var(--text-subtle);
  margin-bottom: 24px;
}

.markdown-body {
  font-size: 15px;
  line-height: 1.75;
}

.markdown-body h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 18px;
}

.markdown-body h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 32px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.markdown-body h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 18px 0 8px;
}

.markdown-body p {
  margin-bottom: 14px;
  color: var(--text);
}

.markdown-body ul {
  list-style: none;
  padding: 0;
  margin: 10px 0 16px;
}

.markdown-body li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 8px;
}

.markdown-body li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--text-subtle);
}

.markdown-body hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 28px 0;
}

.markdown-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  padding: 2px 5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* Tasks & Classes View */
.tasks-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tasks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.events-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.event-card {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.event-card:last-child {
  border-bottom: none;
}

.event-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.event-title {
  font-size: 15px;
  font-weight: 600;
}

.event-meta {
  font-size: 12px;
  color: var(--text-subtle);
  margin-bottom: 10px;
}

.event-type-tag {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

.task-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.task-checkbox {
  appearance: none;
  width: 15px;
  height: 15px;
  border: 1px solid var(--checkbox-border);
  border-radius: 3px;
  cursor: pointer;
  outline: none;
  position: relative;
  background: transparent;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.task-checkbox:checked {
  background: var(--checkbox-checked);
  border-color: var(--checkbox-checked);
}

.task-checkbox:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid var(--checkbox-tick);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

.task-text {
  font-size: 14px;
  color: var(--text);
  transition: color 0.15s ease;
}

.task-text.done {
  text-decoration: line-through;
  color: var(--text-subtle);
}

.no-tasks-hint {
  font-size: 13px;
  color: var(--text-subtle);
  font-style: italic;
}

/* Chat Assistant */
.chat-wrapper {
  display: flex;
  flex-direction: column;
  height: 520px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 16px;
}

.chat-bubble {
  max-width: 85%;
  font-size: 14px;
  line-height: 1.6;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 8px;
}

.chat-bubble.model {
  align-self: flex-start;
  padding: 4px 0;
  color: var(--text);
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.chat-input-bar input {
  flex: 1;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  outline: none;
}

.chat-input-bar input:focus {
  border-color: var(--border-hover);
}

/* Settings */
.settings-wrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 500px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.setting-group input {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  outline: none;
}

.setting-group input:focus {
  border-color: var(--border-hover);
}

.field-hint {
  font-size: 12px;
  color: var(--text-subtle);
}

.sync-box {
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.passkey-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.passkey-item {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.settings-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.status-note {
  font-size: 12px;
  color: var(--text-muted);
}

/* Passkey Modal */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.auth-card h2 {
  font-size: 19px;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.auth-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.auth-btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-btn-group .btn {
  justify-content: center;
  padding: 10px;
  font-size: 14px;
}

.auth-status-msg {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}
