/* ===== OneLine - Private Daily Log ===== */

:root {
  /* Light theme */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --sidebar-width: 320px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --transition: 200ms ease;
}

.dark {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --border: #334155;
  --text: #f1f5f9;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --accent: #818cf8;
  --accent-hover: #6366f1;
  --shadow: 0 1px 3px rgba(0,0,0,0.2), 0 1px 2px rgba(0,0,0,0.15);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.3), 0 4px 6px -2px rgba(0,0,0,0.2);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

/* ===== Layout ===== */

.app-container {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */

.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: background var(--transition), border-color var(--transition);
}

.sidebar-header {
  margin-bottom: 20px;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.logo-tag {
  font-size: 0.75rem;
  color: var(--text-3);
  font-weight: 400;
  letter-spacing: 0.3px;
}

/* ===== Calendar Widget ===== */

.calendar-widget {
  margin-bottom: 16px;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cal-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.cal-nav {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  width: 28px;
  height: 28px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.cal-nav:hover {
  background: var(--surface-2);
  color: var(--text);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-day-label {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-3);
  padding: 4px 0;
  text-transform: uppercase;
}

.cal-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  min-height: 32px;
}

.cal-cell:hover {
  background: var(--surface-2);
}

.cal-empty {
  cursor: default;
}

.cal-empty:hover {
  background: none;
}

.cal-today .cal-day-num {
  background: var(--accent);
  color: white;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.cal-selected {
  background: var(--surface-2);
  border-radius: var(--radius-xs);
}

.cal-day-num {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
}

.cal-mood {
  font-size: 0.55rem;
  line-height: 1;
  margin-top: 1px;
}

.cal-has-entry:not(.cal-today) .cal-day-num {
  font-weight: 600;
}

.today-btn {
  width: 100%;
  margin-top: 8px;
  padding: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.today-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ===== Quick Stats ===== */

.quick-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.qs-item {
  flex: 1;
  text-align: center;
}

.qs-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}

.qs-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== Navigation ===== */

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: auto;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}

.nav-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-btn.active {
  background: var(--accent);
  color: white;
}

.nav-icon {
  font-size: 1.1rem;
}

/* ===== Sidebar Footer ===== */

.sidebar-footer {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 1rem;
  transition: all var(--transition);
}

.icon-btn:hover {
  background: var(--border);
  transform: translateY(-1px);
}

/* ===== Support / Monetization ===== */

.sidebar-support {
  margin-top: 8px;
}

.sidebar-support-actions {
  padding: 4px 0 8px;
}

.support-btn.upgrade {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.8rem;
  text-align: center;
  transition: opacity var(--transition);
}
.support-btn.upgrade:hover {
  opacity: 0.9;
}

.support-toggle {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-2);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}

.support-toggle:hover {
  background: var(--border);
  color: var(--text);
  border-color: var(--accent);
}

.support-panel {
  margin-top: 8px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
}

.support-section {
  margin-bottom: 10px;
}

.support-section:last-child {
  margin-bottom: 0;
}

.support-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.support-btn {
  display: block;
  width: 100%;
  padding: 8px;
  text-align: center;
  border-radius: var(--radius-xs);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all var(--transition);
}

.support-btn.donate {
  background: #ff813f;
  color: #fff;
}

.support-btn.donate:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.affiliate-link {
  display: block;
  padding: 5px 8px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.8rem;
  border-radius: 4px;
  transition: all var(--transition);
}

.affiliate-link:hover {
  background: var(--surface);
  color: var(--accent);
}

.support-disclosure {
  font-size: 0.65rem;
  color: var(--text-3);
  margin-top: 8px;
  line-height: 1.4;
}

/* ===== Main Content ===== */

.main-content {
  flex: 1;
  padding: 40px 48px;
  max-width: 720px;
  transition: background var(--transition);
}

/* ===== Day View ===== */

.day-view {
  animation: fadeIn 250ms ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-bottom: 36px;
}

.date-nav-btn {
  width: 40px;
  height: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  box-shadow: var(--shadow);
}

.date-nav-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  transform: scale(1.05);
}

.day-title {
  text-align: center;
}

.day-today {
  position: relative;
}

.day-name {
  display: block;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-2);
}

.day-date {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.today-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 10px;
  background: var(--accent);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

/* ===== Mood Selector ===== */

.mood-selector {
  margin-bottom: 28px;
}

.section-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
}

.mood-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mood-btn {
  flex: 1;
  min-width: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow);
}

.mood-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--mood-color);
}

.mood-active {
  border-color: var(--mood-color) !important;
  background: color-mix(in srgb, var(--mood-color) 15%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mood-color) 30%, transparent);
}

.mood-emoji {
  font-size: 1.6rem;
  line-height: 1;
}

.mood-label {
  font-size: 0.7rem;
  color: var(--text-2);
  font-weight: 500;
}

/* ===== Journal Input ===== */

.journal-area {
  margin-bottom: 24px;
}

.journal-input {
  width: 100%;
  padding: 16px 20px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  resize: vertical;
  min-height: 120px;
  transition: all var(--transition);
  box-shadow: var(--shadow);
}

.journal-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.journal-input::placeholder {
  color: var(--text-3);
}

.journal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

.char-count {
  font-size: 0.75rem;
  color: var(--text-3);
}

/* ===== Tags ===== */

.tag-area {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid;
  transition: all var(--transition);
}

.tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0.6;
  transition: opacity var(--transition);
  padding: 0 2px;
  color: inherit;
}

.tag-remove:hover {
  opacity: 1;
}

.add-tag-btn {
  padding: 3px 10px;
  background: none;
  border: 1px dashed var(--text-3);
  border-radius: 20px;
  color: var(--text-3);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
}

.add-tag-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== Actions ===== */

.day-actions {
  display: flex;
  gap: 12px;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--accent);
  color: white;
  flex: 1;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
  transform: translateY(-1px);
}

/* ===== Calendar View ===== */

.calendar-view {
  animation: fadeIn 250ms ease;
}

.view-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text);
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.month-block {
  margin-bottom: 24px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}

.month-block:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.month-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 10px;
}

.mg-label {
  text-align: center;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-3);
  padding: 3px 0;
  text-transform: uppercase;
}

.mg-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  position: relative;
  min-height: 28px;
}

.mg-empty {
  visibility: hidden;
}

.mg-num {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-2);
}

.mg-mood {
  font-size: 0.45rem;
  line-height: 1;
  margin-top: 1px;
}

.mg-has-entry {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 4px;
}

.mg-today .mg-num {
  background: var(--accent);
  color: white;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* ===== Stats View ===== */

.stats-view {
  animation: fadeIn 250ms ease;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

.stat-card {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-number {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.stats-section {
  margin-bottom: 28px;
}

/* ===== Mood Chart (Stats) ===== */

.mood-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mood-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mood-bar-emoji {
  font-size: 1.2rem;
  width: 32px;
  text-align: center;
}

.mood-bar-track {
  flex: 1;
  height: 24px;
  background: var(--surface-2);
  border-radius: 12px;
  overflow: hidden;
}

.mood-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 12px;
  transition: width 500ms ease;
  min-width: 4px;
}

.mood-bar-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
  width: 32px;
  text-align: right;
}

/* ===== Tag Cloud ===== */

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tag-cloud-item {
  padding: 4px 12px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  border-radius: 20px;
  color: var(--accent);
  font-weight: 500;
  transition: all var(--transition);
}

.tag-cloud-item:hover {
  background: var(--accent);
  color: white;
  transform: scale(1.05);
}

.tag-cloud-item small {
  font-size: 0.7em;
  opacity: 0.7;
  font-weight: 400;
}

/* ===== Affiliate Card ===== */

.oneline-affiliate-card {
  margin: 24px 48px 24px 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background var(--transition), border-color var(--transition);
}

.oneline-affiliate-header {
  margin-bottom: 16px;
}

.oneline-affiliate-title {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.oneline-affiliate-subtitle {
  display: block;
  font-size: 0.8rem;
  color: var(--text-3);
  margin-top: 2px;
}

.oneline-affiliate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.oneline-affiliate-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--transition);
}

.oneline-affiliate-link:hover {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.oneline-affiliate-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.oneline-affiliate-name {
  line-height: 1.3;
}

.oneline-affiliate-disclosure {
  font-size: 0.65rem;
  color: var(--text-3);
  text-align: center;
  line-height: 1.4;
}

/* ===== Scrollbar ===== */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
}

/* ===== Responsive ===== */

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px;
  }

  .app-container {
    flex-direction: column;
  }

  .main-content {
    padding: 24px 20px;
  }

  .mood-grid {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
  }

  .mood-btn {
    min-width: 56px;
    padding: 8px 4px;
  }

  .mood-emoji {
    font-size: 1.3rem;
  }

  .day-date {
    font-size: 1.4rem;
  }

  .day-header {
    gap: 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-number {
    font-size: 1.5rem;
  }
}
