:root {
  --primary: #ff961b;
  --primary-dark: #e07f00;
  --accent: #ff4d00;
  --cream: #f5e5d0;
  --slate: #304254;
  --dark: #14171c;
  --dark-2: #1f242b;
  --text: #1b1e23;
  --muted: #6b7280;
  --light: #edf0f2;
  --line: #e9e9e9;
  --white: #ffffff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: #fafafa;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.hidden { display: none !important; }

.container { max-width: 1160px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(20, 23, 28, 0.92);
  backdrop-filter: blur(10px);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.header-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-weight: 800;
  font-size: 15px;
}
.logo-text { font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; font-size: 15px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.auth-status { font-size: 13px; color: #a8b3bd; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 11px 20px;
  border-radius: 10px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 6px 18px rgba(255, 77, 0, 0.28);
}
.btn-primary:hover { box-shadow: 0 9px 24px rgba(255, 77, 0, 0.4); }
.btn-ghost {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }
.btn-danger {
  background: #e11d48;
  color: #fff;
}
.btn-danger:hover { background: #be123c; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- Hero ---------- */
.hero {
  margin: 28px 0 40px;
  border-radius: var(--radius);
  background:
    radial-gradient(900px 400px at 90% -10%, rgba(255, 150, 27, 0.45), transparent 60%),
    linear-gradient(135deg, var(--dark) 0%, var(--slate) 100%);
  color: #fff;
  overflow: hidden;
  position: relative;
}
.hero-content { padding: 52px 44px; max-width: 640px; }
.hero-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cream);
  background: rgba(255, 150, 27, 0.16);
  border: 1px solid rgba(255, 150, 27, 0.4);
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 18px;
}
.hero h1 { font-size: 40px; margin-bottom: 14px; }
.hero p { font-size: 16px; color: #d7dee5; max-width: 520px; }
.hero-actions { margin-top: 26px; }

/* ---------- Records section ---------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
}
.section-head h2 { font-size: 22px; color: var(--dark); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip:hover { border-color: var(--primary); color: var(--primary-dark); }
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ---------- Cards / Grid ---------- */
.records-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-media {
  height: 170px;
  background: var(--light);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-media video { width: 100%; height: 100%; object-fit: cover; }
.card-media .media-placeholder { color: var(--muted); font-size: 13px; font-weight: 600; }
.card-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title { font-size: 16px; font-weight: 700; color: var(--dark); }
.card-desc {
  font-size: 13.5px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { margin-top: auto; display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: #9aa3ad; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 6px;
}
.badge-text { background: #eef2ff; color: #4f46e5; }
.badge-paste { background: #ecfdf5; color: #059669; }
.badge-image { background: #fff7ed; color: #ea580c; }
.badge-video { background: #fef2f2; color: #dc2626; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 26px; }
.pagination button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination button.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Modals ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.modal-panel {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-panel-lg { max-width: 760px; }
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.modal-panel h3 { font-size: 20px; margin-bottom: 6px; color: var(--dark); }
.modal-sub { font-size: 14px; color: var(--muted); margin-bottom: 18px; }

.field-label { display: block; font-size: 13px; font-weight: 700; margin: 14px 0 6px; color: var(--dark); }
input[type="text"], input[type="password"], textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border 0.15s ease, box-shadow 0.15s ease;
}
input[type="text"]:focus, input[type="password"]:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 150, 27, 0.18);
}
input[type="file"] { font-size: 13px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 12px; }
.hint code { background: var(--light); padding: 2px 6px; border-radius: 5px; }

.segmented { display: flex; gap: 6px; margin-bottom: 4px; flex-wrap: wrap; }
.seg-btn {
  flex: 1;
  min-width: 70px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 9px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.seg-btn.active { background: var(--dark); color: #fff; border-color: var(--dark); }

/* Detail modal */
.detail-media { margin: 6px 0 16px; border-radius: 10px; overflow: hidden; background: var(--light); }
.detail-media img { width: 100%; display: block; max-height: 420px; object-fit: contain; }
.detail-media video { width: 100%; display: block; max-height: 420px; }
.detail-title { font-size: 22px; color: var(--dark); margin-bottom: 4px; }
.detail-meta { font-size: 13px; color: var(--muted); margin-bottom: 14px; display: flex; gap: 10px; align-items: center; }
.detail-desc { font-size: 15px; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.detail-actions { margin-top: 20px; display: flex; justify-content: flex-end; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--dark);
  color: #fff;
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 200;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #be123c; }
.toast.success { background: #0f9d58; }

/* ---------- Footer ---------- */
.app-footer {
  margin-top: 60px;
  padding: 28px 20px;
  text-align: center;
  color: #a8b3bd;
  background: var(--dark);
  font-size: 13.5px;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .hero-content { padding: 34px 22px; }
  .hero h1 { font-size: 30px; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .records-grid { grid-template-columns: 1fr; }
}

/* ---------- Navigation ---------- */
.main-nav { display: flex; gap: 4px; }
.nav-btn {
  background: transparent;
  border: none;
  color: #cbd5dd;
  font-size: 13.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.nav-btn.active { color: #fff; background: rgba(255, 150, 27, 0.22); }
#nav-home { cursor: pointer; }

/* ---------- Setup view ---------- */
.setup-hero { margin: 28px 0 20px; }
.setup-hero .hero-content { padding: 36px 40px; }
.setup-hero h1 { font-size: 30px; }

.setup-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 22px;
}
.setup-card h2 { font-size: 17px; color: var(--dark); margin-bottom: 16px; }
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border 0.15s ease, box-shadow 0.15s ease;
}
select.input { cursor: pointer; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255, 150, 27, 0.18); }

.btn-ghost-dark { background: transparent; color: var(--dark); border: 1px solid var(--line); }
.btn-ghost-dark:hover { border-color: var(--primary); color: var(--primary-dark); }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* Knowledge base */
.kb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }
.kb-form {
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kb-form h3 { font-size: 14px; color: var(--dark); margin-bottom: 2px; }
.kb-form .btn { margin-top: 4px; }

.kb-list { display: flex; flex-direction: column; gap: 10px; }
.kb-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 18px; border: 1px dashed var(--line); border-radius: 10px; }
.kb-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.kb-item.pinned { border-color: var(--primary); background: #fffaf3; }
.kb-item.muted { opacity: 0.55; }
.kb-item-main { flex: 1; min-width: 0; }
.kb-item-title { font-weight: 700; font-size: 14px; color: var(--dark); margin: 4px 0 2px; }
.kb-item-preview { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-item-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.badge-trik { background: #f5f3ff; color: #7c3aed; }

/* ---------- Copilot ---------- */
.copilot-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: 22px;
  box-shadow: 0 10px 26px rgba(255, 77, 0, 0.4);
  z-index: 90;
  transition: transform 0.15s ease;
}
.copilot-fab:hover { transform: scale(1.06); }

.copilot-panel {
  position: fixed;
  right: 22px;
  bottom: 88px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 95;
}
.copilot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--dark);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}
.copilot-close { background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; line-height: 1; }
.copilot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f6f7f8;
}
.copilot-msg { display: flex; }
.copilot-msg.user { justify-content: flex-end; }
.copilot-msg.assistant { justify-content: flex-start; }
.bubble {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}
.copilot-msg.user .bubble { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; border-bottom-right-radius: 4px; }
.copilot-msg.assistant .bubble { background: #fff; color: var(--text); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.error { background: #fef2f2; color: #be123c; border-color: #fecaca; }
.bubble.typing { color: var(--muted); font-style: italic; }

.copilot-input-row { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: #fff; }
.copilot-input-row input { flex: 1; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: 13.5px; outline: none; }
.copilot-input-row input:focus { border-color: var(--primary); }

/* Tool confirmation card */
.tool-card { background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 12px 14px; font-size: 13px; }
.tool-card.tool-delete { background: #fef2f2; border-color: #fecaca; }
.tool-card-title { font-weight: 700; color: var(--dark); margin-bottom: 6px; }
.tool-card-args { color: var(--muted); margin-bottom: 10px; line-height: 1.5; }
.tool-card-actions { display: flex; gap: 8px; }

@media (max-width: 640px) {
  .kb-grid { grid-template-columns: 1fr; }
  .setup-grid { grid-template-columns: 1fr; }
}

