/* =========================================================
   暗夜书房 · Night Study
   多维日记顾问官 — 全局主题样式
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700;900&family=Playfair+Display:wght@400;600;700;900&display=swap');

/* ---------------------------------------------------------
   1. CSS Variables
   --------------------------------------------------------- */
:root {
  --bg-deep: #0f0d0b;
  --bg: #1a1714;
  --bg-elevated: #242019;
  --card: rgba(36, 32, 25, 0.85);
  --card-solid: #242019;
  --border: rgba(196, 167, 110, 0.15);
  --border-hover: rgba(196, 167, 110, 0.3);
  --text: #e8dcc8;
  --text-secondary: #a89a82;
  --text-dim: #6b6052;
  --accent: #c4a76e;
  --accent-glow: rgba(196, 167, 110, 0.25);
  --accent-hover: #d4b87e;
  --accent-deep: #8b7340;
  --soft-blue: rgba(196, 167, 110, 0.12);
  --soft-blue-text: #c4a76e;
  --danger-bg: rgba(180, 60, 60, 0.15);
  --danger-text: #e8a0a0;
  --ok-bg: rgba(80, 160, 80, 0.15);
  --ok-text: #a0d8a0;
  --shadow-warm: 0 10px 40px rgba(15, 13, 11, 0.35);
  --shadow-warm-lg: 0 20px 60px rgba(15, 13, 11, 0.5);
  --shadow-glow: 0 0 30px rgba(196, 167, 110, 0.08);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --font-serif: "Noto Serif SC", "Playfair Display", "Georgia", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-display: "Playfair Display", "Noto Serif SC", serif;
  --transition-fast: 0.12s ease;
  --transition-normal: 0.2s ease;
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------------------------------------------------------
   2. Global Reset & Base
   --------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  animation: pageLoadFadeIn 0.6s ease both;
}

button,
input,
textarea,
select {
  font-family: inherit;
}

p {
  color: var(--text-secondary);
  margin: 0 0 8px;
}

/* ---------------------------------------------------------
   3. Utility Classes
   --------------------------------------------------------- */
.hidden {
  display: none !important;
}

.center {
  text-align: center;
}

.between {
  justify-content: space-between;
  align-items: center;
}

/* ---------------------------------------------------------
   4. Animations & Keyframes
   --------------------------------------------------------- */
@keyframes pageLoadFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes subtleGlow {
  0%, 100% {
    box-shadow: var(--shadow-warm), var(--shadow-glow);
  }
  50% {
    box-shadow: var(--shadow-warm), 0 0 50px rgba(196, 167, 110, 0.12);
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* ---------------------------------------------------------
   5. Login Page
   --------------------------------------------------------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 25% 20%, rgba(196, 167, 110, 0.08), transparent 50%),
    radial-gradient(ellipse at 75% 80%, rgba(139, 115, 64, 0.06), transparent 45%),
    radial-gradient(ellipse at 50% 50%, rgba(36, 32, 25, 0.5), transparent 70%),
    var(--bg-deep);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-warm-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: cardEntrance 0.5s ease both;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: var(--bg-deep);
  font-size: 13px;
  font-weight: 800;
  font-family: var(--font-serif);
  margin-bottom: 20px;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 16px rgba(196, 167, 110, 0.2);
}

.login-card h1 {
  font-family: var(--font-serif);
  font-size: 28px;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.login-copy {
  line-height: 1.7;
  margin-top: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.login-action {
  width: 100%;
  margin-top: 18px;
}

/* ---------------------------------------------------------
   6. App Shell & Layout
   --------------------------------------------------------- */
.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.topbar h1 {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.topbar p {
  font-size: 13px;
  color: var(--text-dim);
  margin: 4px 0 0;
}

/* ---------------------------------------------------------
   7. Typography
   --------------------------------------------------------- */
h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: -0.02em;
  color: var(--text);
  font-weight: 700;
}

h2 {
  margin: 0 0 12px;
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
}

h3 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 17px;
  color: var(--text);
  font-weight: 700;
}

.hint {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
}

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--soft-blue);
  color: var(--soft-blue-text);
}

.badge.ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.badge.danger-badge {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.status-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status {
  background: var(--bg-elevated);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--border);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.status.subtle {
  background: var(--soft-blue);
  color: var(--soft-blue-text);
  border-color: rgba(196, 167, 110, 0.1);
}

/* ---------------------------------------------------------
   8. Panels & Tabs
   --------------------------------------------------------- */
.panel {
  display: none;
  animation: pageLoadFadeIn 0.3s ease both;
}

.panel.active {
  display: block;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tab,
button {
  border: 0;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  transition:
    transform 0.08s ease,
    background var(--transition-normal),
    color var(--transition-normal),
    box-shadow var(--transition-normal);
}

button:active {
  transform: scale(0.97);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.tab.active,
button:not(.secondary):not(.danger):not(.ghost) {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: var(--bg-deep);
  box-shadow: 0 4px 16px rgba(196, 167, 110, 0.2);
}

button:not(.secondary):not(.danger):not(.ghost):hover {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  box-shadow: 0 6px 24px rgba(196, 167, 110, 0.3);
}

/* ---------------------------------------------------------
   9. Cards
   --------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-warm);
  margin-bottom: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition:
    box-shadow var(--transition-normal),
    border-color var(--transition-normal),
    transform var(--transition-normal);
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-warm), var(--shadow-glow);
}

.capture-card {
  padding: 22px;
}

/* ---------------------------------------------------------
   10. Form Elements
   --------------------------------------------------------- */
label {
  display: block;
  font-weight: 700;
  margin: 14px 0 6px;
  color: var(--text);
  font-size: 14px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  font-size: 16px;
  background: var(--bg-elevated);
  color: var(--text);
  outline: none;
  transition:
    border-color var(--transition-normal),
    box-shadow var(--transition-normal),
    background var(--transition-normal);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-dim);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  background: var(--bg);
}

textarea {
  resize: vertical;
  line-height: 1.65;
  min-height: 170px;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a89a82' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

select option {
  background: var(--bg-elevated);
  color: var(--text);
}

input[readonly] {
  background: var(--bg);
  color: var(--text-dim);
  border-color: rgba(196, 167, 110, 0.08);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 600;
  color: var(--text-secondary);
}

.check input {
  width: auto;
  accent-color: var(--accent);
}

/* ---------------------------------------------------------
   11. Buttons
   --------------------------------------------------------- */
.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.quick-actions {
  align-items: stretch;
}

.primary-action {
  min-height: 64px;
  font-size: 22px;
  border-radius: var(--radius-lg);
  padding: 16px 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: var(--bg-deep);
  font-weight: 800;
  box-shadow: 0 4px 20px rgba(196, 167, 110, 0.2);
  transition:
    transform 0.08s ease,
    box-shadow var(--transition-normal),
    background var(--transition-normal);
}

.primary-action:hover {
  box-shadow: 0 6px 30px rgba(196, 167, 110, 0.35);
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
}

.primary-action:active {
  transform: scale(0.97);
  box-shadow: 0 2px 12px rgba(196, 167, 110, 0.15);
}

#sendRecord {
  flex: 1 1 260px;
  min-width: 220px;
}

.quick-btn {
  min-height: 58px;
  font-size: 20px;
  border-radius: var(--radius-lg);
  flex: 0 1 116px;
}

.quick-btn.wide {
  flex-basis: 150px;
}

.secondary {
  background: var(--soft-blue);
  color: var(--soft-blue-text);
  border: 1px solid rgba(196, 167, 110, 0.1);
  transition:
    background var(--transition-normal),
    border-color var(--transition-normal),
    box-shadow var(--transition-normal),
    transform 0.08s ease;
}

.secondary:hover {
  background: rgba(196, 167, 110, 0.2);
  border-color: rgba(196, 167, 110, 0.25);
  box-shadow: 0 4px 16px rgba(196, 167, 110, 0.1);
}

.secondary:active {
  transform: scale(0.97);
}

.ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition:
    background var(--transition-normal),
    color var(--transition-normal),
    border-color var(--transition-normal),
    transform 0.08s ease;
}

.ghost:hover {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border);
}

.ghost:active {
  transform: scale(0.97);
}

.danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid rgba(180, 60, 60, 0.2);
  transition:
    background var(--transition-normal),
    border-color var(--transition-normal),
    transform 0.08s ease;
}

.danger:hover {
  background: rgba(180, 60, 60, 0.25);
  border-color: rgba(180, 60, 60, 0.35);
}

.danger:active {
  transform: scale(0.97);
}

.small-btn {
  min-height: auto;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
}

.small-primary {
  min-height: auto;
  font-size: 15px;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: var(--bg-deep);
  font-weight: 800;
  box-shadow: 0 4px 16px rgba(196, 167, 110, 0.2);
  transition:
    transform 0.08s ease,
    box-shadow var(--transition-normal);
}

.small-primary:hover {
  box-shadow: 0 6px 24px rgba(196, 167, 110, 0.3);
}

.small-primary:active {
  transform: scale(0.97);
}

.summary-action {
  width: 100%;
  margin-top: 10px;
}

/* ---------------------------------------------------------
   12. Result Boxes
   --------------------------------------------------------- */
.result {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-deep);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  min-height: 64px;
  line-height: 1.65;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", "Menlo", monospace;
  font-size: 14px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

.result.compact {
  min-height: 0;
  margin-top: 14px;
}

.result:empty {
  display: none;
}

.result.large {
  min-height: 360px;
}

/* ---------------------------------------------------------
   13. Record Items & Timeline
   --------------------------------------------------------- */
.record-item {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  transition: background var(--transition-fast);
}

.record-item:last-child {
  border-bottom: none;
}

.record-time {
  color: var(--text-dim);
  font-size: 13px;
}

.record-text {
  margin-top: 6px;
  line-height: 1.7;
  font-size: 15px;
  color: var(--text);
}

.record-location {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 13px;
}

.date-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.date-toolbar input {
  min-width: 170px;
  width: auto;
}

.record-time-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.record-main-time {
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0.01em;
  color: var(--text);
  font-family: var(--font-serif);
}

.record-sub-time {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 13px;
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}

/* ---------------------------------------------------------
   14. Record Comments
   --------------------------------------------------------- */
.record-comment-panel {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid rgba(196, 167, 110, 0.12);
  border-radius: var(--radius-md);
  background: rgba(196, 167, 110, 0.04);
}

.record-comments {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.record-comment {
  border-left: 4px solid var(--accent-deep);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

.comment-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 6px;
}

.comment-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.comment-text {
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: 14px;
  color: var(--text);
}

.comment-empty {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 8px;
}

.comment-edit {
  margin-top: 10px;
}

/* ---------------------------------------------------------
   15. Record Edit
   --------------------------------------------------------- */
.record-edit {
  margin-top: 12px;
  padding: 14px;
  border: 1px dashed var(--border-hover);
  border-radius: var(--radius-md);
  background: rgba(196, 167, 110, 0.03);
}

/* ---------------------------------------------------------
   16. Timeline Search Grid
   --------------------------------------------------------- */
.timeline-search-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

/* ---------------------------------------------------------
   17. Record Detail, Search, Todos
   --------------------------------------------------------- */
.detail-panel {
  border: 1px solid var(--border-hover);
  background: var(--card);
}

.detail-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.detail-section h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-family: var(--font-serif);
}

.detail-section p {
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text-secondary);
}

.detail-comment {
  background: var(--bg-elevated);
  border-left: 4px solid var(--accent-deep);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.related-record {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  margin: 8px 0;
  transition: border-color var(--transition-fast);
}

.related-record:hover {
  border-color: var(--border-hover);
}

.todo-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  margin: 8px 0;
  transition: border-color var(--transition-fast);
}

.todo-item:hover {
  border-color: var(--border-hover);
}

.todo-candidates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.todo-candidates p {
  flex-basis: 100%;
  margin: 0;
}

/* ---------------------------------------------------------
   18. AI Workspaces
   --------------------------------------------------------- */
.workspace-create-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
}

.workspace-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}

.workspace-sidebar {
  position: sticky;
  top: 12px;
}

.workspace-list-item {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 10px;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

.workspace-list-item:hover {
  background: var(--bg);
  border-color: var(--border-hover);
  color: var(--text);
}

.workspace-list-item.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: var(--bg-deep);
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(196, 167, 110, 0.2);
}

.workspace-list-item strong {
  display: block;
  margin-bottom: 4px;
  font-weight: 700;
}

.workspace-list-item span {
  font-size: 12px;
  color: inherit;
  opacity: 0.7;
}

.workspace-main {
  min-height: 520px;
}

.workspace-empty {
  padding: 30px;
  text-align: center;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  background: rgba(196, 167, 110, 0.02);
}

.workspace-header {
  align-items: flex-start;
}

.workspace-memory-box {
  border: 1px solid rgba(196, 167, 110, 0.12);
  background: rgba(196, 167, 110, 0.04);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 14px;
}

.workspace-memory {
  white-space: pre-wrap;
  word-break: break-word;
  background: transparent;
  color: var(--text-secondary);
  padding: 8px;
  margin: 0;
  max-height: 180px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.55;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", "Menlo", monospace;
  border: none;
  box-shadow: none;
}

.workspace-memory:focus {
  border: none;
  box-shadow: none;
}

.workspace-chat {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  padding: 14px;
  min-height: 260px;
  max-height: 480px;
  overflow: auto;
  margin-bottom: 12px;
}

.workspace-msg {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  line-height: 1.65;
  word-break: break-word;
  animation: pageLoadFadeIn 0.25s ease both;
}

.workspace-msg.user {
  margin-left: auto;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: var(--bg-deep);
  box-shadow: 0 2px 12px rgba(196, 167, 110, 0.15);
}

.workspace-msg.assistant {
  margin-right: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
}

.workspace-msg-meta {
  font-size: 12px;
  opacity: 0.6;
  margin-bottom: 4px;
}

.workspace-composer {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 12px;
  align-items: stretch;
}

.workspace-composer textarea {
  min-height: 92px;
}

.workspace-ledger-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.workspace-ledger-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 10px;
  background: var(--bg-elevated);
  transition: border-color var(--transition-fast);
}

.workspace-ledger-item:hover {
  border-color: var(--border-hover);
}

.workspace-ledger-item p {
  margin: 6px 0;
  line-height: 1.55;
  color: var(--text-secondary);
}

.workspace-ledger-details summary {
  cursor: pointer;
  font-weight: 900;
  font-size: 18px;
  font-family: var(--font-serif);
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.workspace-ledger-details summary::before {
  content: "\25B6";
  font-size: 12px;
  color: var(--accent);
  transition: transform var(--transition-fast);
}

.workspace-ledger-details[open] summary::before {
  transform: rotate(90deg);
}

/* ---------------------------------------------------------
   19. Dynamic Workspace Views
   --------------------------------------------------------- */
.workspace-dynamic-card {
  overflow: hidden;
}

.workspace-view-blocks {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.dynamic-view-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-warm);
  transition: border-color var(--transition-normal);
}

.dynamic-view-block:hover {
  border-color: var(--border-hover);
}

.dynamic-block-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding: 20px 22px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.dynamic-block-head h3 {
  margin: 0;
  font-size: 22px;
  font-family: var(--font-serif);
  color: var(--text);
}

.dynamic-table-wrap {
  width: 100%;
  overflow: auto;
}

.dynamic-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.dynamic-table th,
.dynamic-table td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  line-height: 1.55;
  color: var(--text);
}

.dynamic-table th {
  background: var(--bg);
  font-weight: 900;
  color: var(--accent);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dynamic-table td:last-child,
.dynamic-table th:last-child {
  border-right: none;
}

.dynamic-list,
.dynamic-card-grid,
.dynamic-board,
.dynamic-timeline,
.dynamic-metrics,
.dynamic-markdown {
  padding: 18px 22px;
}

.dynamic-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dynamic-list-item,
.dynamic-board-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 15px;
  background: var(--bg);
  line-height: 1.65;
  color: var(--text);
  transition: border-color var(--transition-fast);
}

.dynamic-list-item:hover,
.dynamic-board-item:hover {
  border-color: var(--border-hover);
}

.dynamic-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.dynamic-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  background: var(--bg);
  line-height: 1.6;
  color: var(--text);
  transition:
    border-color var(--transition-normal),
    box-shadow var(--transition-normal);
}

.dynamic-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-glow);
}

.dynamic-card strong {
  display: block;
  font-size: 17px;
  margin-bottom: 6px;
  color: var(--text);
}

.dynamic-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.dynamic-fields span {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 8px;
  color: var(--text-secondary);
}

.dynamic-fields b {
  display: block;
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 4px;
  font-weight: 600;
}

.dynamic-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  align-items: start;
}

.dynamic-board-col {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  min-height: 120px;
}

.dynamic-board-col h4 {
  margin: 0 0 10px 0;
  font-family: var(--font-serif);
  color: var(--text);
}

.dynamic-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dynamic-timeline-item {
  border-left: 4px solid var(--accent-deep);
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  color: var(--text);
}

.dynamic-timeline-item span {
  display: block;
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 4px;
}

.dynamic-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.dynamic-metric {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  background: var(--bg);
  transition: border-color var(--transition-fast);
}

.dynamic-metric:hover {
  border-color: var(--border-hover);
}

.dynamic-metric span {
  display: block;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 6px;
}

.dynamic-metric strong {
  font-size: 24px;
  color: var(--accent);
  font-family: var(--font-display);
}

/* ---------------------------------------------------------
   20. Sidebar Navigation (Desktop >=721px)
   --------------------------------------------------------- */
.sidebar-nav {
  display: none;
}

#tab-more {
  display: none;
}

.sidebar-brand {
  padding: 6px 8px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.sidebar-brand strong {
  display: block;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
  font-family: var(--font-serif);
}

.sidebar-sub {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 500;
}

.sidebar-section-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 14px 0 6px;
  padding-left: 10px;
  font-weight: 700;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text-secondary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 0;
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast);
}

.sidebar-item:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.sidebar-item.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: var(--bg-deep);
  box-shadow: 0 2px 12px rgba(196, 167, 110, 0.15);
}

.sidebar-item.admin-only {
  color: var(--accent-deep);
}

.sidebar-item.admin-only.active {
  background: linear-gradient(135deg, var(--accent-deep), #6b5530);
  color: var(--text);
}

.sidebar-item-ic {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--bg-elevated);
  flex-shrink: 0;
  display: inline-block;
  transition: background var(--transition-fast);
}

.sidebar-item.active .sidebar-item-ic {
  background: rgba(15, 13, 11, 0.25);
}

.sidebar-item.admin-only .sidebar-item-ic {
  background: rgba(196, 167, 110, 0.2);
}

.sidebar-item.admin-only.active .sidebar-item-ic {
  background: rgba(255, 255, 255, 0.2);
}

/* ---------------------------------------------------------
   21. PWA Elements
   --------------------------------------------------------- */
.connection-banner {
  position: fixed;
  top: env(safe-area-inset-top, 0);
  left: 0;
  right: 0;
  z-index: 80;
  padding: 10px 14px;
  background: var(--bg-deep);
  color: var(--accent);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(15, 13, 11, 0.4);
}

.pwa-install,
.pwa-update {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0));
  z-index: 75;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-warm-lg);
  padding: 12px 14px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.pwa-install span,
.pwa-update span {
  display: block;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
}

.pwa-install strong {
  color: var(--text);
}

.pwa-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.offline-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-deep);
}

/* ---------------------------------------------------------
   22. Offline Draft Panel
   --------------------------------------------------------- */
.offline-draft-panel {
  margin-top: 16px;
}

.draft-item {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.draft-item:first-child {
  border-top: 0;
}

.draft-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.draft-text {
  white-space: pre-wrap;
  line-height: 1.6;
  color: var(--text-secondary);
}

.draft-status {
  color: var(--text-muted);
}

/* ---------------------------------------------------------
   23. User Management
   --------------------------------------------------------- */
.user-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  color: var(--text);
}

.user-row:last-child {
  border-bottom: none;
}

.user-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-actions button {
  padding: 8px 10px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

/* ---------------------------------------------------------
   24. Profile / Account
   --------------------------------------------------------- */
.profile-status-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.profile-status {
  display: block;
  width: 100%;
  text-align: left;
}

.account-card .actions {
  margin-top: 18px;
}

/* ---------------------------------------------------------
   25. Mobile Record Hero
   --------------------------------------------------------- */
.mobile-record-hero {
  margin-bottom: 8px;
}

.mobile-kicker {
  display: inline-flex;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--soft-blue);
  color: var(--soft-blue-text);
  font-weight: 800;
  font-size: 12px;
  margin-bottom: 8px;
  border: 1px solid rgba(196, 167, 110, 0.1);
}

.mobile-record-hero h2 {
  font-size: 24px;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
  font-family: var(--font-serif);
}

.mobile-record-hero p {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.record-location-inline {
  margin-top: 2px;
}

.record-location-inline label,
.record-text-label {
  margin-top: 8px;
}

/* ---------------------------------------------------------
   26. Mobile Composer Row
   --------------------------------------------------------- */
.mobile-composer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  gap: 10px;
  align-items: stretch;
}

.composer-send {
  min-width: 0;
  width: 100%;
  border-radius: var(--radius-lg);
  font-size: 17px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: var(--bg-deep);
  box-shadow: 0 4px 16px rgba(196, 167, 110, 0.2);
  transition:
    transform 0.08s ease,
    box-shadow var(--transition-normal);
}

.composer-send:hover {
  box-shadow: 0 6px 24px rgba(196, 167, 110, 0.3);
}

.composer-send:active {
  transform: scale(0.97);
}

.mobile-composer-row textarea#recordText {
  min-height: 96px;
  resize: vertical;
}

.composer-focused .pwa-install,
.composer-focused .pwa-update {
  display: none !important;
}

/* ---------------------------------------------------------
   27. More Page (Mobile)
   --------------------------------------------------------- */
.more-card {
  padding: 18px;
}

.more-section-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 14px 0 8px;
  padding-left: 4px;
  font-weight: 700;
}

.more-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 700;
  position: relative;
  cursor: pointer;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast);
}

.more-row:hover {
  background: var(--bg);
  border-color: var(--border-hover);
}

.more-row.admin-only {
  background: rgba(196, 167, 110, 0.06);
  border-color: rgba(196, 167, 110, 0.15);
}

.more-row .more-row-title {
  display: block;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}

.more-row .more-row-sub {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 500;
}

.more-row .more-row-arrow {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 20px;
  font-weight: 400;
}

/* ---------------------------------------------------------
   28. Scrollbar Styling
   --------------------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-deep);
}

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

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

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent-deep) var(--bg-deep);
}

/* ---------------------------------------------------------
   29. Decorative Elements
   --------------------------------------------------------- */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.03;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(196, 167, 110, 0.08) 2px,
      rgba(196, 167, 110, 0.08) 3px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 2px,
      rgba(196, 167, 110, 0.05) 2px,
      rgba(196, 167, 110, 0.05) 3px
    );
}

.shell,
.login-shell {
  position: relative;
  z-index: 1;
}

/* ---------------------------------------------------------
   30. Selection Styling
   --------------------------------------------------------- */
::selection {
  background: rgba(196, 167, 110, 0.3);
  color: var(--text);
}

/* ---------------------------------------------------------
   31. Focus Visible (Accessibility)
   --------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------
   32. Responsive — Desktop (>=721px)
   --------------------------------------------------------- */
@media (min-width: 721px) {
  #appShell.shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 24px;
    max-width: 1240px;
    align-items: start;
    padding: 20px 24px 24px;
  }

  #appShell.shell > .sidebar-nav {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 12px 14px;
    box-shadow: var(--shadow-warm);
    max-height: calc(100vh - 32px);
    overflow: auto;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  /* Desktop: hide topbar and bottom tabs, use sidebar */
  #appShell.shell > .topbar.app-minimal-topbar {
    display: none;
  }

  #appShell.shell > .tabs {
    display: none;
  }

  #appShell.shell > #tab-more {
    display: none !important;
  }

  /* Main panel fills second column */
  #appShell.shell > .panel {
    grid-column: 2;
  }

  .mobile-record-hero {
    display: none;
  }

  /* Workspace responsive */
  @media (max-width: 860px) {
    .workspace-layout,
    .workspace-ledger-grid,
    .workspace-create-grid,
    .workspace-composer {
      grid-template-columns: 1fr;
    }
    .workspace-sidebar {
      position: static;
    }
    .workspace-msg {
      max-width: 96%;
    }
  }
}

/* ---------------------------------------------------------
   33. Responsive — Mobile (<=720px)
   --------------------------------------------------------- */
@media (max-width: 720px) {
  html,
  body {
    min-height: 100%;
    overflow-x: hidden;
  }

  body {
    background: var(--bg-deep);
  }

  .login-shell {
    align-items: stretch;
    padding: 18px 16px;
    min-height: 100svh;
  }

  .login-card {
    max-width: 100%;
    border-radius: var(--radius-xl);
    padding: 24px 20px;
    margin: auto 0;
  }

  .login-card h1 {
    font-size: 25px;
  }

  .shell {
    max-width: none;
    padding: 14px 12px calc(88px + env(safe-area-inset-bottom, 0));
  }

  .topbar {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
    padding: 16px;
    border-radius: var(--radius-lg);
    background: var(--card);
    border: 1px solid var(--border);
    margin-bottom: 12px;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .topbar p {
    font-size: 13px;
  }

  .status-group {
    width: 100%;
    align-items: stretch;
    justify-content: flex-start;
  }

  .status {
    width: 100%;
    font-size: 12px;
  }

  /* Bottom tab bar */
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 65;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(76px, 1fr);
    overflow-x: auto;
    gap: 6px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0));
    background: var(--card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -16px 40px rgba(15, 13, 11, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    margin-bottom: 0;
  }

  .tab {
    min-width: 76px;
    padding: 10px 8px;
    border-radius: var(--radius-md);
    font-size: 13px;
    text-align: center;
    white-space: nowrap;
    background: var(--bg-elevated);
    color: var(--text-dim);
  }

  .tab.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: var(--bg-deep);
    box-shadow: 0 4px 16px rgba(196, 167, 110, 0.2);
  }

  .panel {
    margin-top: 12px;
  }

  .card {
    border-radius: var(--radius-xl);
    padding: 16px;
  }

  .field-row,
  .grid {
    grid-template-columns: 1fr;
  }

  textarea#recordText {
    min-height: 34svh;
    font-size: 17px;
    line-height: 1.7;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .quick-actions .primary-action {
    grid-column: 1 / -1;
  }

  .quick-actions .wide {
    grid-column: 1 / -1;
  }

  .actions.between {
    align-items: flex-start;
    gap: 12px;
  }

  .date-toolbar {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    justify-content: flex-start;
  }

  .date-toolbar input,
  .date-toolbar button {
    width: 100%;
  }

  .record-time-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .record-actions {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .record-main-time {
    font-size: 18px;
  }

  .record-sub-time {
    font-size: 13px;
  }

  .user-row {
    grid-template-columns: 1fr;
  }

  .user-actions {
    justify-content: flex-start;
  }

  /* PWA cards mobile */
  .pwa-install,
  .pwa-update {
    left: 10px;
    right: 10px;
    bottom: calc(76px + env(safe-area-inset-bottom, 0));
    border-radius: var(--radius-lg);
  }

  /* Sidebar hidden on mobile */
  #appShell.shell > .sidebar-nav {
    display: none !important;
  }

  #appShell.shell > .tabs > .tab.tab-mobile-hidden {
    display: none !important;
  }

  /* More page */
  #tab-more.panel.active {
    display: block;
  }

  /* Workspace responsive */
  .workspace-layout,
  .workspace-ledger-grid,
  .workspace-create-grid,
  .workspace-composer {
    grid-template-columns: 1fr;
  }

  .workspace-sidebar {
    position: static;
  }

  .workspace-msg {
    max-width: 96%;
  }

  /* Dynamic views mobile */
  .dynamic-block-head {
    padding: 16px;
    align-items: center;
  }

  .dynamic-block-head h3 {
    font-size: 19px;
  }

  .dynamic-table th,
  .dynamic-table td {
    padding: 13px 14px;
  }

  .dynamic-list,
  .dynamic-card-grid,
  .dynamic-board,
  .dynamic-timeline,
  .dynamic-metrics,
  .dynamic-markdown {
    padding: 14px;
  }
}

/* ---------------------------------------------------------
   34. Mobile Record First Layout (<=720px)
   --------------------------------------------------------- */
@media (max-width: 720px) {
  .shell {
    padding: 8px 10px calc(84px + env(safe-area-inset-bottom, 0));
  }

  .topbar {
    display: none;
  }

  .tabs {
    grid-auto-columns: minmax(68px, 1fr);
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom, 0));
  }

  .tab {
    min-width: 68px;
    padding: 10px 6px;
    font-size: 13px;
  }

  .panel {
    margin-top: 0;
  }

  #tab-record.active {
    display: block;
  }

  .record-first-card {
    min-height: calc(100svh - 94px - env(safe-area-inset-bottom, 0));
    margin: 0;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-radius: var(--radius-xl);
  }

  .mobile-record-hero {
    flex: 0 0 auto;
    margin-bottom: 0;
  }

  .mobile-record-hero h2 {
    font-size: 23px;
  }

  .mobile-record-hero p {
    font-size: 13px;
  }

  .record-text-label {
    position: absolute;
    left: -9999px;
  }

  textarea#recordText {
    flex: 1 1 30svh;
    min-height: 30svh;
    max-height: 42svh;
    font-size: 17px;
    line-height: 1.65;
    border-radius: var(--radius-lg);
    padding: 14px;
  }

  .record-hint-desktop {
    display: none;
  }

  .record-location-inline {
    flex: 0 0 auto;
  }

  .record-location-inline label {
    font-size: 13px;
    margin: 0 0 6px;
  }

  .record-location-inline input {
    min-height: 48px;
    border-radius: var(--radius-md);
  }

  .mobile-primary-actions {
    flex: 0 0 auto;
    margin-top: 4px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }

  .mobile-primary-actions .primary-action {
    grid-column: 1 / -1;
    min-height: 54px;
    font-size: 20px;
    border-radius: var(--radius-lg);
  }

  #sendRecord {
    min-width: 0;
    width: 100%;
  }

  .mobile-primary-actions .quick-btn {
    min-height: 46px;
    font-size: 16px;
    border-radius: var(--radius-md);
    padding: 10px 8px;
  }

  .mobile-primary-actions .quick-btn.wide {
    grid-column: 1 / -1;
    min-height: 48px;
  }

  #recordResult {
    margin-top: 10px;
  }
}

/* ---------------------------------------------------------
   35. Mobile Keyboard Safe Composer (<=720px)
   --------------------------------------------------------- */
@media (max-width: 720px) {
  body.composer-focused {
    overflow: hidden;
  }

  .mobile-composer-row {
    grid-template-columns: minmax(0, 1fr) 74px;
    gap: 8px;
  }

  .record-first-card {
    transition:
      bottom 0.16s ease,
      box-shadow 0.16s ease,
      transform 0.16s ease;
  }

  .mobile-composer-row textarea#recordText {
    min-height: 112px;
    max-height: 34svh;
  }

  .composer-send {
    min-height: 52px;
    padding: 0 10px;
    writing-mode: horizontal-tb;
  }

  .composer-focused #tab-record {
    padding-bottom: 150px;
  }

  .composer-focused .record-first-card {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(var(--keyboard-offset, 0px) + env(safe-area-inset-bottom, 0px) + 8px);
    z-index: 90;
    min-height: auto;
    max-height: calc(100svh - var(--keyboard-offset, 0px) - 24px);
    padding: 10px;
    border-radius: var(--radius-xl);
    box-shadow: 0 18px 60px rgba(15, 13, 11, 0.6);
  }

  .composer-focused .mobile-record-hero,
  .composer-focused .record-hint-desktop,
  .composer-focused .record-location-inline,
  .composer-focused .mobile-secondary-actions,
  .composer-focused #recordResult {
    display: none !important;
  }

  .composer-focused .mobile-composer-row textarea#recordText {
    min-height: 46px;
    max-height: 128px;
    height: auto;
    font-size: 17px;
    line-height: 1.45;
    padding: 11px 12px;
  }

  .composer-focused .composer-send {
    height: 48px;
    min-height: 48px;
    border-radius: var(--radius-md);
    align-self: end;
  }
}

/* ---------------------------------------------------------
   36. Mobile Keyboard & Workspace Composer Fixes (<=720px)
   --------------------------------------------------------- */
@media (max-width: 720px) {
  body.keyboard-visible {
    overflow: hidden;
  }

  body.keyboard-visible .workspace-main {
    padding-bottom: 150px;
  }

  body.keyboard-visible .workspace-chat {
    max-height: calc(100svh - var(--keyboard-offset, 0px) - 260px);
  }

  body.workspace-composer-focused .workspace-composer {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(var(--keyboard-offset, 0px) + env(safe-area-inset-bottom, 0px) + 8px);
    z-index: 95;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 88px;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--card-solid);
    box-shadow: 0 18px 60px rgba(15, 13, 11, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  body.workspace-composer-focused .workspace-composer textarea {
    min-height: 48px;
    max-height: 128px;
    font-size: 17px;
    line-height: 1.45;
    resize: none;
  }

  body.workspace-composer-focused #sendWorkspaceMessage {
    min-height: 48px;
    padding: 0 10px;
    border-radius: var(--radius-md);
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: var(--bg-deep);
    box-shadow: 0 4px 16px rgba(196, 167, 110, 0.2);
  }

  body:not(.keyboard-visible).composer-focused .mobile-secondary-actions,
  body:not(.keyboard-visible).composer-focused .record-location-inline,
  body:not(.keyboard-visible).composer-focused #recordResult {
    display: flex !important;
  }

  body:not(.keyboard-visible).composer-focused .record-first-card {
    position: static;
    box-shadow: var(--shadow-warm);
    max-height: none;
  }

  body:not(.keyboard-visible).composer-focused #tab-record {
    padding-bottom: 0;
  }
}

/* ---------------------------------------------------------
   37. Staggered Card Entrance Animation
   --------------------------------------------------------- */
.card:nth-child(1) { animation-delay: 0s; }
.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.1s; }
.card:nth-child(4) { animation-delay: 0.15s; }
.card:nth-child(5) { animation-delay: 0.2s; }

.panel.active .card {
  animation: cardEntrance 0.4s ease both;
}

.panel.active .card:nth-child(1) { animation-delay: 0s; }
.panel.active .card:nth-child(2) { animation-delay: 0.06s; }
.panel.active .card:nth-child(3) { animation-delay: 0.12s; }
.panel.active .card:nth-child(4) { animation-delay: 0.18s; }
.panel.active .card:nth-child(5) { animation-delay: 0.24s; }

/* ---------------------------------------------------------
   38. Hover Lift Effect for Interactive Cards
   --------------------------------------------------------- */
.workspace-list-item:hover,
.dynamic-card:hover,
.related-record:hover,
.todo-item:hover {
  transform: translateY(-1px);
  transition:
    transform var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

/* ---------------------------------------------------------
   39. Warm Ambient Glow Behind Key Cards
   --------------------------------------------------------- */
.capture-card::before,
.workspace-main::before {
  content: "";
  position: absolute;
  top: -40px;
  left: -40px;
  right: -40px;
  bottom: -40px;
  background: radial-gradient(
    ellipse at center,
    rgba(196, 167, 110, 0.04),
    transparent 70%
  );
  pointer-events: none;
  z-index: -1;
  border-radius: 50%;
}

.capture-card,
.workspace-main {
  position: relative;
}

/* ---------------------------------------------------------
   40. Print Styles (Dark to Light Fallback)
   --------------------------------------------------------- */
@media print {
  body {
    background: #fff;
    color: #111;
  }

  .card {
    background: #fff;
    border-color: #ddd;
    box-shadow: none;
  }

  .sidebar-nav,
  .tabs,
  .topbar,
  .connection-banner,
  .pwa-install,
  .pwa-update {
    display: none !important;
  }
}

.danger-btn{border-color:rgba(180,83,9,.35)!important;color:#f4d8a8!important}
.danger-btn:hover{border-color:rgba(220,38,38,.65)!important;color:#fecaca!important}

/* v2.2.0 LifeOS overview */
.lifeos-stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(92px,1fr));gap:10px;margin-top:18px}.lifeos-stat{padding:14px 12px;border:1px solid var(--border-soft);border-radius:var(--radius-md);background:rgba(255,255,255,.035)}.lifeos-stat strong{display:block;font-size:24px;line-height:1;color:var(--accent)}.lifeos-stat span{display:block;margin-top:6px;font-size:13px;color:var(--text-muted)}.lifeos-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:16px}.lifeos-section-card{min-height:180px}.lifeos-section-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:10px}.lifeos-section-head h3{margin:0;font-size:18px}.lifeos-section-head span{min-width:28px;height:28px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;background:rgba(196,167,110,.12);color:var(--accent);font-weight:900}.lifeos-item{padding:12px 0;border-top:1px solid var(--border-soft)}.lifeos-item:first-of-type{border-top:none}.lifeos-item strong{display:block;font-size:15px;margin-bottom:4px}.lifeos-item p{margin:0 0 4px 0;color:var(--text-main);font-size:14px;line-height:1.55;white-space:pre-wrap}.lifeos-item small{display:block;color:var(--text-muted);line-height:1.5}.vault-item small{color:var(--accent)}.error-text{color:#fecaca}@media(max-width:720px){.lifeos-grid{grid-template-columns:1fr}.lifeos-stats{grid-template-columns:repeat(3,1fr)}}

/* v2.2.3 LifeOS Dynamic Task Views */
.lifeos-query-card textarea{
  width:100%;
  min-height:84px;
  resize:vertical;
  margin-top:12px;
}
.lifeos-query-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
}
.lifeos-query-actions{
  margin-top:12px;
  align-items:center;
}
.lifeos-query-chip{
  white-space:nowrap;
}
.lifeos-query-result{
  margin-top:16px;
  display:grid;
  gap:14px;
}
.lifeos-answer-block .dynamic-markdown{
  color:var(--text-main);
  line-height:1.75;
}
.lifeos-query-meta{
  margin-top:10px;
}
@media(max-width:720px){
  .lifeos-query-actions{
    display:grid;
    grid-template-columns:1fr 1fr;
  }
  #runLifeOSQuery{
    grid-column:1 / -1;
  }
  .lifeos-query-chip{
    width:100%;
  }
}


/* v2.2.4 LifeOS Interactive Task Checkboxes */
.lifeos-task-title-row{display:flex;align-items:flex-start;gap:10px;min-width:0}
.lifeos-task-title-text{min-width:0;flex:1}
.lifeos-task-checkbox{width:22px;height:22px;min-width:22px;border-radius:6px;border:1.5px solid rgba(90,124,154,.75);background:rgba(255,255,255,.72);color:#1f6e8c;display:inline-flex;align-items:center;justify-content:center;font-weight:900;font-size:15px;line-height:1;cursor:pointer;margin-top:1px;box-shadow:0 1px 4px rgba(31,42,68,.08);transition:transform .12s ease,background .12s ease,border-color .12s ease}
.lifeos-task-checkbox:hover{transform:translateY(-1px);border-color:#1f6e8c;background:rgba(232,244,252,.95)}
.lifeos-task-checkbox.checked{background:#e8f6ef;border-color:#2d8a57;color:#207244}
.lifeos-task-checkbox.syncing{opacity:.55;cursor:wait;transform:none}
.lifeos-task-done .lifeos-task-title-text,.lifeos-task-done>strong{opacity:.72;text-decoration:line-through;text-decoration-thickness:1.5px;text-underline-offset:3px}
.lifeos-task-done td:not(.task-check-col){opacity:.72;text-decoration:line-through;text-decoration-thickness:1.5px}
.task-check-col{width:56px;text-align:center;white-space:nowrap}
.lifeos-toggle-result{margin-top:10px;padding:0 4px}
@media(max-width:720px){.lifeos-task-checkbox{width:26px;height:26px;min-width:26px;border-radius:8px}.task-check-col{width:48px}}

/* v3.1.0 Task Toggle Timeline + Stable Focus */
.record-assistant-panel {
  margin-top: 14px;
  border-color: rgba(58, 122, 177, 0.22);
}
.record-assistant-result {
  display: grid;
  gap: 12px;
}
.record-assistant-panel .dynamic-view-block {
  margin-top: 10px;
}
.record-assistant-panel .lifeos-answer-block {
  border-color: rgba(58, 122, 177, 0.18);
}
@media (max-width: 720px) {
  .record-assistant-panel {
    margin: 12px 0;
    padding: 14px;
  }
  .record-assistant-panel .dynamic-block-head {
    gap: 8px;
  }
}


/* v3.1.0 task checkbox stable focus */
.lifeos-task-checkbox:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.lifeos-task-checkbox.syncing { opacity: 0.65; pointer-events: none; }


/* v3.1.0 Conversational Ledger UI */
.record-chat-card {
  padding: 18px;
}

.record-chat-stream {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 58vh;
  min-height: 240px;
  overflow-y: auto;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 20% 0%, rgba(196, 167, 110, 0.08), transparent 28%),
    var(--bg-deep);
}

.record-chat-empty {
  color: var(--text-dim);
  text-align: center;
  padding: 42px 18px;
  line-height: 1.8;
}

.record-chat-message {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: min(92%, 820px);
}

.record-chat-message.from-user {
  align-self: flex-end;
  align-items: flex-end;
}

.record-chat-message.from-assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.record-chat-meta {
  font-size: 12px;
  color: var(--text-dim);
  padding: 0 4px;
}

.record-chat-bubble {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 8px 26px rgba(0,0,0,0.12);
  overflow-x: auto;
}

.record-chat-message.from-user .record-chat-bubble {
  background: linear-gradient(135deg, rgba(196, 167, 110, 0.22), rgba(196, 167, 110, 0.12));
  border-color: rgba(196, 167, 110, 0.28);
}

.record-chat-message.from-assistant .record-chat-bubble {
  min-width: min(100%, 620px);
}

.record-chat-bubble .dynamic-view-block {
  margin: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
  padding: 0;
}

.record-chat-bubble .dynamic-view-block + .dynamic-view-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.record-chat-bubble .dynamic-block-head {
  margin-bottom: 10px;
}

.record-chat-bubble .dynamic-table-wrap {
  max-width: 100%;
}

.record-chat-bubble .dynamic-table {
  font-size: 13px;
}

@media (max-width: 720px) {
  .record-chat-card {
    padding: 12px;
  }

  .record-chat-stream {
    min-height: 260px;
    max-height: calc(100svh - 310px);
    padding: 10px;
    gap: 12px;
  }

  .record-chat-message {
    max-width: 96%;
  }

  .record-chat-bubble {
    padding: 10px 11px;
    border-radius: 16px;
  }

  .record-chat-message.from-assistant .record-chat-bubble {
    min-width: 0;
    width: 100%;
  }

  .record-chat-bubble .dynamic-table {
    font-size: 12px;
  }
}



/* v3.1.0 Task delete action */
.task-action-col {
  width: 72px;
  text-align: center;
  white-space: nowrap;
}

.lifeos-task-delete-btn {
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(180, 60, 60, 0.35);
  background: rgba(180, 60, 60, 0.12);
  color: var(--danger-text);
}

.lifeos-task-delete-btn:hover {
  background: rgba(180, 60, 60, 0.22);
}

.lifeos-task-delete-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* v3.1.0 Local Management Directory */
.local-dir-card code { white-space: normal; word-break: break-all; }
.local-dir-card .actions.wrap { gap: 8px; }
#localManagementDir { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

/* v3.1.0 Local Workspace Kernel */
.workspace-kernel-card textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.workspace-file-grid { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.workspace-file-grid .align-end { align-self: end; }
@media (max-width: 760px) { .workspace-file-grid { grid-template-columns: 1fr; } }
