/* ============================
   Reset & Base
   ============================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #2e2e2e;
  --text: #e0e0e0;
  --text-muted: #888;
  --accent: #00ff88;
  --warn: #ffcc00;
  --danger: #ff4444;
  --mono: "JetBrains Mono", "Courier New", monospace;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  font-weight: 400;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================
   Navbar
   ============================ */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.nav-links { display: flex; gap: 1.5rem; }
.nav-links a { color: var(--text-muted); font-size: 0.9rem; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-inline-form { display: inline-flex; }
.nav-btn { padding: 0.25rem 0.55rem; }

/* ============================
   Layout
   ============================ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ============================
   Flash message
   ============================ */
.flash {
  background: #1a3a2a;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.6rem 1rem;
  border-radius: 6px;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

/* ============================
   Stats Bar
   ============================ */
.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1 1 130px;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.phase-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: middle;
}
.phase-morning { background: #f59e0b; }
.phase-work { background: #3b82f6; }
.phase-afternoon { background: #f97316; }
.phase-evening { background: #a855f7; }
.phase-night { background: #4b5563; }
.phase-unknown { background: #6b7280; }

/* ============================
   Controls Bar
   ============================ */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  margin-bottom: 1.25rem;
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.label-inline {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.select-inline {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.3rem 0.6rem;
  border-radius: 5px;
  font-size: 0.85rem;
  cursor: pointer;
}

/* ============================
   Buttons
   ============================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  text-decoration: none;
}
.btn:hover { opacity: 0.85; text-decoration: none; }

.btn-ok   { background: var(--accent); color: #000; }
.btn-warn { background: var(--warn); color: #000; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm   { padding: 0.3rem 0.7rem; font-size: 0.8rem; background: var(--surface2); border: 1px solid var(--border); color: var(--text); }
.btn-lg   { padding: 0.6rem 1.4rem; font-size: 0.95rem; }

/* ============================
   Card
   ============================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
}

/* ============================
   Table
   ============================ */
.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  white-space: nowrap;
}

.table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table tr:hover td { background: var(--surface2); }

.note-preview {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.news-icon {
  margin-right: 0.35rem;
}

.link-view {
  color: var(--accent);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ============================
   Badges
   ============================ */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.badge-running   { background: #003a20; color: var(--accent); font-size: 1rem; padding: 0.3rem 0.75rem; border: 1px solid var(--accent); }
.badge-paused    { background: #3a3000; color: var(--warn); font-size: 1rem; padding: 0.3rem 0.75rem; border: 1px solid var(--warn); }
.badge-done      { background: #003a20; color: var(--accent); }
.badge-running-sm{ background: #003a20; color: var(--accent); }
.badge-error     { background: #3a0000; color: var(--danger); }
.badge-gray      { background: #2a2a2a; color: var(--text-muted); }

/* ============================
   Pagination
   ============================ */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  justify-content: center;
}

.page-info { color: var(--text-muted); font-size: 0.85rem; }

/* ============================
   Empty state
   ============================ */
.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
  font-size: 0.9rem;
}

/* ============================
   Model name
   ============================ */
.model-name {
  font-family: var(--mono);
  font-size: 0.8em;
  color: #aaa;
}

/* ============================
   Session detail
   ============================ */
.session-card { max-width: 860px; margin: 0 auto; }

.session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.session-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.meta-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 110px;
}

.meta-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.meta-value { font-size: 0.9rem; font-weight: 600; }

.note-section { margin-bottom: 1.5rem; }

.note-heading {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.note-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  min-height: 60px;
}

.note-box-news {
  border-color: #3b82f6;
}

.note-empty { color: var(--text-muted); font-style: italic; font-family: system-ui, sans-serif; }
.note-error { color: var(--danger); }

/* ============================
   Login
   ============================ */
.login-wrap {
  min-height: calc(100vh - 140px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 420px;
}

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
}

/* ============================
   Schedule
   ============================ */
.schedule-timeline {
  margin-top: 0.75rem;
}

.schedule-track {
  position: relative;
  display: flex;
  height: 22px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.schedule-block {
  height: 100%;
}

.schedule-now-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: #fff;
  opacity: 0.9;
}

.schedule-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 0.45rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.phase-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.25rem;
}

.phase-card {
  padding: 1rem;
}

.phase-card-title {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.phase-card .note-box {
  margin-top: 0.6rem;
  min-height: 90px;
}

.phase-card-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 255, 136, 0.3) inset;
}

.phase-active-label {
  margin-top: 0.5rem;
  color: var(--accent);
  font-size: 0.8rem;
}

/* ============================
   Settings form
   ============================ */
.settings-note {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.settings-form { display: flex; flex-direction: column; gap: 1.25rem; }

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }

.settings-subsection {
  padding-top: 0.4rem;
  border-top: 1px dashed var(--border);
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.form-control {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  width: 100%;
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
}

.form-textarea {
  font-family: var(--mono);
  font-size: 0.85rem;
  resize: vertical;
  line-height: 1.6;
}

.confirm-block {
  background: #1a0000;
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-top: 2rem;
}

.confirm-block p {
  color: #ffaaaa;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.confirm-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.reset-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--danger);
}

/* ============================
   Workspace
   ============================ */
.workspace-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.25rem;
  align-items: start;
}

.workspace-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  position: sticky;
  top: 4rem;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.75rem;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  transition: background 0.1s;
}

.file-item:hover {
  background: var(--surface2);
  text-decoration: none;
}

.file-item-active {
  background: var(--surface2);
  border-left: 2px solid var(--accent);
  padding-left: calc(0.75rem - 2px);
}

.file-name {
  font-family: var(--mono);
  font-size: 0.82rem;
  word-break: break-all;
}

.file-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: 0.5rem;
}

.workspace-content {
  min-width: 0;
}

.workspace-file-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.workspace-empty-content {
  color: var(--text-muted);
  padding: 3rem;
  text-align: center;
  font-size: 0.9rem;
}

/* ============================
   Responsive
   ============================ */
@media (max-width: 640px) {
  .container { padding: 1rem; }
  .stats-bar { gap: 0.5rem; }
  .stat { flex: 1 1 100px; padding: 0.6rem 0.75rem; }
  .controls-bar { flex-direction: column; align-items: flex-start; }
  .session-meta { gap: 0.5rem; }
  .note-box { font-size: 0.82rem; }
  .workspace-layout {
    grid-template-columns: 1fr;
  }
  .workspace-sidebar {
    position: static;
  }
}
