/* Core responsive styles — mobile-first */

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-input: #232633;
  --bg-hover: #2a2e3d;
  --border: #2e3246;
  --text: #e4e6ef;
  --text-dim: #8b8fa3;
  --accent: #6c8cff;
  --accent-hover: #5a7ae8;
  --danger: #e85454;
  --danger-hover: #d04040;
  --success: #4caf7c;
  --warning: #d4a843;
  --radius: 10px;
  --radius-sm: 6px;
  --nav-height: 60px;
  --header-height: 48px;
}

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

html {
  background: var(--bg-card);
}

body {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Date bar */
.date-bar {
  flex-shrink: 0;
  height: var(--header-height);
  padding-top: env(safe-area-inset-top, 0px);
  /* Total height = header + safe area, but use min-height so safe area adds to it */
  min-height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.date-nav {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.date-nav:hover {
  background: var(--bg-hover);
}

.date-display {
  background: none;
  border: none;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  min-width: 160px;
  text-align: center;
}

.date-display:hover {
  background: var(--bg-hover);
}

.date-picker-hidden {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* Main content */
main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: none;
}

main > * {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px;
}

main {
  padding: 12px 0;
}

/* Bottom nav */
.bottom-nav {
  flex-shrink: 0;
  min-height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 100;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 11px;
  transition: color 0.15s;
}

.tab.active {
  color: var(--accent);
}

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

.tab-icon {
  width: 22px;
  height: 22px;
}

/* Toast notifications */
#toast-container {
  position: fixed;
  top: calc(var(--header-height) + env(safe-area-inset-top, 0px) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  opacity: 0;
  transform: translateY(-8px);
  animation: toast-in 0.2s forwards, toast-out 0.2s 2.5s forwards;
  pointer-events: auto;
}

.toast-success {
  background: var(--success);
  color: #fff;
}

.toast-error {
  background: var(--danger);
  color: #fff;
}

@keyframes toast-in {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(-8px); }
}

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 600;
}

/* Panels (category picker, form) */
.panel {
  background: var(--bg);
  padding: 0 0 16px;
}

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

.panel-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 32px 16px;
}

/* Placeholder page */
.placeholder-page {
  text-align: center;
  padding: 48px 16px;
}

.placeholder-page h2 {
  font-size: 22px;
  margin-bottom: 12px;
}

.placeholder-page .hint {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 8px;
}

/* Scrollable on small screens */
@media (max-width: 640px) {
  main {
    padding: 10px 0;
  }
  main > * {
    padding: 0 12px;
  }
}
