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

:root {
  --bg:          #0d1117;
  --bg2:         #161b22;
  --bg3:         #21262d;
  --bg4:         #2d333b;
  --border:      #30363d;
  --border2:     #444c56;
  --text:        #e6edf3;
  --text2:       #adbac7;
  --muted:       #768390;
  --accent:      #539bf5;
  --accent-dim:  #1c2d43;
  --success:     #57ab5a;
  --warning:     #c69026;
  --danger:      #e5534b;
  --high:        #e5534b;
  --medium:      #c69026;
  --low:         #57ab5a;
  --radius:      6px;
  --radius-lg:   10px;
  --shadow:      0 8px 24px rgba(1,4,9,.6);
  --font:        -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono:        "JetBrains Mono", "Fira Code", "Cascadia Code", ui-monospace, monospace;
}

html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; }
#app { height: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Boot screen ─────────────────────────────────────────────────────────── */
.boot-screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.boot-logo {
  font-size: 48px;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:.3} 50%{opacity:1} }

/* ── Auth pages ──────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at top, #161b22 0%, var(--bg) 70%);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
}
.auth-card--wide { max-width: 560px; }
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  font-size: 18px;
  font-weight: 600;
}
.logo-icon { font-size: 26px; color: var(--accent); }
.auth-desc { color: var(--muted); margin-bottom: 20px; font-size: 13px; }
.qr-container { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 20px; }
.qr-image { border-radius: 8px; border: 4px solid #fff; }
.qr-secret { font-size: 12px; color: var(--muted); text-align: center; }
.qr-secret code { font-family: var(--mono); color: var(--text2); background: var(--bg3); padding: 2px 6px; border-radius: 4px; margin-left: 4px; }

/* ── Form elements ───────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

input[type=text], input[type=password], input[type=email], input[type=color],
textarea, select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  transition: border-color .15s;
}
input[type=text]:focus, input[type=password]:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(83,155,245,.15);
}
input[type=color] { padding: 4px; height: 36px; cursor: pointer; }
textarea { resize: vertical; min-height: 100px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23768390' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: #6aadff; border-color: #6aadff; }
.btn-ghost { background: transparent; color: var(--text2); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg3); color: var(--text); border-color: var(--border2); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger:hover:not(:disabled) { background: rgba(229,83,75,.15); border-color: var(--danger); }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 7px; font-size: 11px; }
.btn-icon { padding: 6px 10px; font-size: 16px; background: transparent; color: var(--text2); border: none; border-radius: var(--radius); cursor: pointer; transition: color .15s, background .15s; }
.btn-icon:hover:not(:disabled) { color: var(--text); background: var(--bg3); }
.btn-icon:disabled { opacity: .3; cursor: not-allowed; }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; font-size: inherit; padding: 0; }
.btn-link:hover { text-decoration: underline; }
.btn-row { display: flex; gap: 8px; justify-content: flex-end; }

/* ── App shell ───────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100%;
  overflow: hidden;
}
.sidebar {
  width: 200px;
  min-width: 200px;
  background: #010409;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
  overflow: hidden;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0 16px;
  font-size: 28px;
  color: var(--accent);
}
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sidebar-bottom { padding-top: 8px; border-top: 1px solid var(--border); }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  text-align: left;
}
.nav-item:hover { background: var(--bg3); color: var(--text2); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-icon { font-size: 16px; flex-shrink: 0; }
.nav-label { flex: 1; }

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
}
.loading { color: var(--muted); padding: 40px; text-align: center; }

/* ── Section headers ─────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.section-header h2 { font-size: 20px; font-weight: 600; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  box-shadow: var(--shadow);
  transform: translateY(8px);
  opacity: 0;
  transition: transform .2s, opacity .2s;
  z-index: 9999;
  max-width: 320px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-error { border-color: var(--danger); color: var(--danger); }
.toast-success { border-color: var(--success); color: var(--success); }

/* ── Journal ─────────────────────────────────────────────────────────────── */
.date-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}
.date-display { display: flex; flex-direction: column; }
.date-weekday { font-size: 15px; font-weight: 600; color: var(--text); }

.journal-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  height: calc(100vh - 130px);
}
.journal-notes, .journal-tasks {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}
.panel-header h3 { font-size: 13px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; }
.task-counter { font-size: 12px; color: var(--muted); background: var(--bg4); padding: 1px 8px; border-radius: 10px; }

.notes-editor {
  flex: 1;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  padding: 16px;
  resize: none;
  outline: none;
}
.notes-editor:focus { box-shadow: none; border-color: transparent; }
.notes-preview {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.7;
}
.notes-preview h1,.notes-preview h2,.notes-preview h3 { margin: 16px 0 8px; color: var(--text); }
.notes-preview p { margin-bottom: 10px; color: var(--text2); }
.notes-preview code { font-family: var(--mono); background: var(--bg3); padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.notes-preview pre { background: var(--bg3); padding: 12px; border-radius: var(--radius); overflow-x: auto; margin-bottom: 12px; }
.notes-preview ul,.notes-preview ol { padding-left: 20px; margin-bottom: 10px; color: var(--text2); }
.notes-preview blockquote { border-left: 3px solid var(--border2); padding-left: 12px; color: var(--muted); margin-bottom: 10px; }
.hidden { display: none !important; }

.tasks-list { flex: 1; overflow-y: auto; padding: 8px; }
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius);
  transition: background .1s;
  margin-bottom: 2px;
}
.task-item:hover { background: var(--bg3); }
.task-item:hover .btn-task-del { opacity: 1; }
.task-item.done .task-text { color: var(--muted); text-decoration: line-through; }

.task-check { flex-shrink: 0; position: relative; width: 18px; height: 18px; margin-top: 2px; }
.task-check input { opacity: 0; width: 100%; height: 100%; cursor: pointer; position: absolute; margin: 0; }
.checkmark {
  display: block;
  width: 18px; height: 18px;
  border: 2px solid var(--border2);
  border-radius: 4px;
  transition: background .15s, border-color .15s;
  pointer-events: none;
  position: relative;
}
.task-check input:checked ~ .checkmark {
  background: var(--accent);
  border-color: var(--accent);
}
.task-check input:checked ~ .checkmark::after {
  content: '';
  position: absolute;
  left: 4px; top: 1px;
  width: 6px; height: 10px;
  border: 2px solid #fff;
  border-top: none; border-left: none;
  transform: rotate(45deg);
}

.task-text {
  flex: 1;
  font-size: 13px;
  line-height: 1.5;
  outline: none;
  word-break: break-word;
  min-width: 0;
}
.task-text:focus { color: var(--text); }
.btn-task-del {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0;
  transition: opacity .15s;
}
.add-task-form {
  display: flex;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid var(--border);
}
.add-task-form input { font-size: 13px; }

/* ── Filter bar ──────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-btn {
  padding: 5px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.filter-btn:hover { border-color: var(--border2); color: var(--text2); }
.filter-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* ── Projects grid ───────────────────────────────────────────────────────── */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.project-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent, #539bf5);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: border-color .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.project-card:hover { box-shadow: 0 4px 16px rgba(1,4,9,.5); }
.project-card-header { display: flex; align-items: center; gap: 8px; }
.project-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.project-status-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.project-name { font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.3; }
.project-desc { font-size: 13px; color: var(--text2); line-height: 1.5; }
.project-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.project-links { display: flex; flex-wrap: wrap; gap: 6px; }
.project-link { font-size: 12px; color: var(--accent); }
.project-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; }

/* ── Tags ────────────────────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text2);
  font-family: var(--mono);
}

/* ── Ideas ───────────────────────────────────────────────────────────────── */
.ideas-add-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.ideas-add-bar input { flex: 1; }
.ideas-add-bar select { width: auto; flex-shrink: 0; }
.ideas-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text2);
}
.toggle-label input[type=checkbox] { width: auto; cursor: pointer; accent-color: var(--accent); }

.ideas-list { display: flex; flex-direction: column; gap: 6px; }
.idea-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--radius);
  transition: background .1s;
}
.idea-item:hover { background: var(--bg3); }
.idea-item:hover .idea-actions { opacity: 1; }
.idea-item.priority-high { border-left-color: var(--high); }
.idea-item.priority-medium { border-left-color: var(--medium); }
.idea-item.priority-low { border-left-color: var(--low); }
.idea-item.done { opacity: .55; }
.idea-item.done .idea-text { text-decoration: line-through; color: var(--muted); }
.idea-priority { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.idea-text { flex: 1; font-size: 13px; line-height: 1.5; outline: none; word-break: break-word; }
.idea-tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.idea-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .15s;
  flex-shrink: 0;
}

/* ── Diagrams ────────────────────────────────────────────────────────────── */
.diagrams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.diagram-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.diagram-card:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(1,4,9,.5); }
.diagram-thumb {
  width: 100%;
  height: 130px;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.diagram-thumb img { width: 100%; height: 100%; object-fit: contain; }
.diagram-thumb-placeholder { font-size: 40px; opacity: .3; }
.diagram-info {
  padding: 10px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.diagram-name { font-size: 13px; font-weight: 600; color: var(--text); }
.diagram-date { font-size: 11px; color: var(--muted); }
.diagram-actions {
  display: flex;
  gap: 4px;
  padding: 0 8px 10px;
}

/* ── Diagram overlay ─────────────────────────────────────────────────────── */
.diagram-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.diagram-overlay.hidden { display: none; }
.diagram-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}
#drawio-iframe { flex: 1; width: 100%; border: none; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(1,4,9,.75);
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal--wide { max-width: 900px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { color: var(--text); background: var(--bg3); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--bg3); flex-shrink: 0; }

.project-modal-body { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.modal-col { display: flex; flex-direction: column; gap: 0; }
.modal-col--docs { display: flex; flex-direction: column; }
.modal-col--docs .form-group { flex: 1; display: flex; flex-direction: column; }
.docs-editor { flex: 1; min-height: 300px; font-family: var(--mono); font-size: 12px; }
.flex-grow { flex: 1; }

.link-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.link-row .link-label { flex: 0 0 110px; }
.link-row .link-url { flex: 1; }
.btn-del-link { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 16px; padding: 2px 4px; border-radius: 3px; flex-shrink: 0; }
.btn-del-link:hover { background: rgba(229,83,75,.15); }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  grid-column: 1/-1;
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border2); }

/* ── Mobile bottom nav (hidden on desktop) ───────────────────────────────── */
.mobile-nav { display: none; }

/* ── Mobile (≤ 768px) ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  html, body { overflow: auto; }
  #app { height: auto; min-height: 100%; }

  /* App shell: column layout, sidebar hidden */
  .app-shell { flex-direction: column; height: auto; min-height: 100dvh; }
  .sidebar { display: none; }
  .main-content { padding: 16px 12px 88px; overflow-y: visible; }

  /* Bottom navigation bar */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #010409;
    border-top: 1px solid var(--border);
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 2px;
    background: transparent;
    border: none;
    color: var(--muted);
    font-family: var(--font);
    font-size: 10px;
    cursor: pointer;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav-item.active { color: var(--accent); }
  .mobile-nav-icon { font-size: 22px; line-height: 1; }

  /* Journal: stack panels vertically */
  .journal-body { grid-template-columns: 1fr; height: auto; gap: 12px; }
  .journal-notes { height: 55vh; min-height: 260px; }
  .journal-tasks { min-height: 220px; max-height: 60vh; }

  /* Date navigation */
  .date-nav { flex-wrap: wrap; gap: 6px; }
  .date-weekday { font-size: 13px; }

  /* Section header */
  .section-header { gap: 8px; margin-bottom: 14px; }
  .section-header h2 { font-size: 17px; }

  /* Stack form rows on mobile */
  .form-row { flex-direction: column; gap: 0; }

  /* Projects: single column */
  .projects-grid { grid-template-columns: 1fr; }

  /* Ideas: stack add bar */
  .ideas-add-bar { flex-direction: column; gap: 6px; }
  .ideas-add-bar select { width: 100%; }
  .ideas-add-bar .btn { width: 100%; justify-content: center; }
  .ideas-toolbar { flex-wrap: wrap; }

  /* Idea items: always show actions */
  .idea-actions { opacity: 1; }

  /* Diagrams: 2 columns on medium, 1 on very small */
  .diagrams-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* Modal: bottom sheet style */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    max-height: 92dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .modal--wide { max-width: 100%; }
  .project-modal-body { grid-template-columns: 1fr; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 10px 16px; }
  .docs-editor { min-height: 180px; }

  /* Btn-row wraps on mobile */
  .btn-row { flex-wrap: wrap; gap: 8px; }

  /* Toast: above bottom nav */
  .toast { bottom: 76px; right: 12px; left: 12px; max-width: none; }

  /* Prevent iOS auto-zoom on focus (requires font-size >= 16px) */
  input[type=text], input[type=password], input[type=email],
  input[type=color], textarea, select { font-size: 16px; }

  /* Larger touch targets */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  .btn-xs { min-height: 30px; }
  .btn-icon { min-height: 40px; min-width: 40px; }
  .filter-btn { min-height: 34px; padding: 6px 16px; }
  .btn-task-del { opacity: 1; font-size: 18px; padding: 2px 6px; }
  .nav-item, .mobile-nav-item { -webkit-tap-highlight-color: transparent; }

  /* Smooth scroll */
  .main-content, .tasks-list, .notes-preview, .modal-body { -webkit-overflow-scrolling: touch; }
}

/* ── Very small screens (≤ 400px) ───────────────────────────────────────── */
@media (max-width: 400px) {
  .diagrams-grid { grid-template-columns: 1fr; }
  .mobile-nav-item { font-size: 9px; }
  .mobile-nav-icon { font-size: 20px; }
}

/* ════════════════════════════════════════════════════════════
   IDEAS HUB — sub-navigation
════════════════════════════════════════════════════════════ */
.hub-subnav {
  display: flex; gap: 0.25rem; margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--border); padding-bottom: 0;
}
.hub-tab {
  background: none; border: none; cursor: pointer;
  padding: 0.6rem 1rem; font-size: 0.88rem; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s; border-radius: 6px 6px 0 0;
  display: flex; align-items: center; gap: 0.4rem; white-space: nowrap;
}
.hub-tab:hover { color: var(--text); background: var(--bg-hover, rgba(255,255,255,0.05)); }
.hub-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
#hub-body { flex: 1; min-height: 0; }

/* ════════════════════════════════════════════════════════════
   DOCKER
════════════════════════════════════════════════════════════ */
.docker-stats-row {
  display: flex; gap: 1.5rem; margin-bottom: 1.25rem;
  padding: 0.75rem 1rem; background: var(--bg-card); border-radius: 8px;
  border: 1px solid var(--border);
}
.dstat { font-size: 0.85rem; color: var(--text-muted); }
.dstat b { color: var(--text); font-size: 1rem; margin-right: 0.25rem; }
.containers-list { display: flex; flex-direction: column; gap: 0.5rem; }
.container-card {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.75rem 1rem; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 8px;
  transition: border-color 0.15s;
}
.container-card:hover { border-color: var(--accent); }
.container-status-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.container-info { flex: 1; min-width: 0; }
.container-name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.container-image { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.container-ports { font-size: 0.75rem; color: var(--text-muted); font-family: monospace; }
.container-badge {
  padding: 2px 8px; border-radius: 12px; font-size: 0.72rem;
  font-weight: 600; white-space: nowrap; flex-shrink: 0;
}
.container-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }
.btn-xs { padding: 2px 7px !important; font-size: 0.78rem !important; }
.modal--logs .modal-body { padding: 0; }
.logs-box {
  font-family: 'Courier New', monospace; font-size: 0.78rem;
  background: #0d1117; color: #c9d1d9; padding: 1rem;
  max-height: 65vh; overflow-y: auto; white-space: pre-wrap; word-break: break-all;
}
.log-line { line-height: 1.5; }
.logs-loading { padding: 2rem; text-align: center; color: var(--text-muted); }
.error-state { color: var(--danger, #f47067); }

/* ════════════════════════════════════════════════════════════
   MONITORING
════════════════════════════════════════════════════════════ */
.monitor-services {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.service-card {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.25rem; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 10px;
  text-decoration: none; color: var(--text);
  transition: border-color 0.15s, transform 0.1s;
  border-left: 3px solid var(--scolor, var(--accent));
}
.service-card:hover { border-color: var(--scolor, var(--accent)); transform: translateY(-1px); }
.service-icon { font-size: 1.5rem; flex-shrink: 0; }
.service-info { flex: 1; min-width: 0; }
.service-name { font-weight: 600; font-size: 0.9rem; }
.service-desc { font-size: 0.77rem; color: var(--text-muted); }
.service-arrow { color: var(--text-muted); font-size: 1.1rem; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem 1.25rem;
}
.stat-card--wide { grid-column: 1 / -1; }
.stat-title { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; }
.stat-value { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.5rem; }
.stat-value--lg { font-size: 1.1rem; }
.stat-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }
.stat-bar {
  height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.stat-bar-fill {
  height: 100%; border-radius: 3px;
  transition: width 0.4s ease, background 0.4s ease;
}

/* ════════════════════════════════════════════════════════════
   EMBED FRAME (Grafana / Portainer / Zabbix)
════════════════════════════════════════════════════════════ */
.embed-wrap {
  display: flex; flex-direction: column;
  height: calc(100vh - 60px);
  margin: -1.5rem;
}
.embed-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 1rem; background: var(--bg-card);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.embed-title { font-weight: 600; font-size: 0.95rem; }
.embed-auth-status { font-size: 0.8rem; color: var(--text-muted); }
.embed-frame {
  flex: 1; border: none; width: 100%; height: 100%;
  background: var(--bg);
}
