/* ==========================================================================
   ARDesign Editorial Spatial Management — Online Knowledge Base (/knowledge.css)
   Unified with Main CRM Dashboard (Warm Cream #FEFCF7 × Warm Sand #F7F3EA × Orange #EA5504)
   ========================================================================== */
:root {
  color-scheme: light;
  --bg-canvas: #FEFCF7;
  --bg-surface: #FFFFFF;
  --bg-Warm: #F7F3EA;
  --bg-soft: #F6F2E9;
  --text-ink: #4C4C4C;
  --text-strong: #262625;
  --text-muted: #888888;
  --accent-orange: #EA5504;
  --accent-orange-hover: #D14800;
  --accent-orange-soft: #FDF3EB;
  --line-hair: #E5E0D8;
  --line-strong: #D5CFC4;
  font-family: "Plus Jakarta Sans", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

html.dark {
  color-scheme: dark;
  --bg-canvas: #161615;
  --bg-surface: #1F1F1D;
  --bg-Warm: #22211E;
  --bg-soft: #262522;
  --text-ink: #EAE6DF;
  --text-strong: #FFFFFF;
  --text-muted: #8E8A82;
  --accent-orange: #FF6414;
  --accent-orange-hover: #EA5504;
  --accent-orange-soft: rgba(255, 100, 20, 0.14);
  --line-hair: #2E2D29;
  --line-strong: #3E3C37;
}

* {
  box-sizing: border-box;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background-color: var(--bg-canvas);
  color: var(--text-ink);
  font-family: "Plus Jakarta Sans", "Noto Sans TC", sans-serif;
  letter-spacing: 0.015em;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent-orange);
  color: #FFFFFF;
}

button, input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-orange); }

/* Editorial Marquee Bar */
@keyframes marqueeScroll {
  0% { transform: translateX(0%); }
  100% { transform: translateX(-50%); }
}

.las-marquee-bar {
  overflow: hidden;
  border-bottom: 1px solid var(--line-hair);
  background: var(--bg-Warm);
  padding: 6px 0;
  user-select: none;
}

.marquee-track {
  display: flex;
  width: max-content;
  animation: marqueeScroll 34s linear infinite;
}

.marquee-group {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 16px;
  font-family: "IBM Plex Mono", "Noto Sans TC", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  white-space: nowrap;
}

.marquee-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-orange);
  margin-right: 6px;
  vertical-align: middle;
}

.marquee-accent {
  color: var(--accent-orange);
  font-weight: 600;
}

/* Top Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 62px;
  background: rgba(254, 252, 247, 0.94);
  backdrop-filter: blur(12px);
  color: var(--text-strong);
  border-bottom: 1px solid var(--line-hair);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 28px;
  gap: 16px;
}

html.dark .topbar {
  background: rgba(22, 22, 21, 0.94);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 128px;
  height: 36px;
  object-fit: contain;
}

html.dark .brand-logo {
  filter: brightness(1.18) saturate(1.08);
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.brand strong {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-strong);
}

.brand strong span {
  color: var(--accent-orange);
}

.brand small,
.eyebrow,
.side-caption,
.side-footer {
  font-family: "IBM Plex Mono", "Noto Sans TC", monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.brand small {
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.account-pill {
  font-family: "IBM Plex Mono", "Noto Sans TC", monospace;
  font-size: 12px;
  color: var(--text-muted);
  padding-right: 4px;
}

.theme-pill,
.back-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line-hair);
  background: var(--bg-surface);
  color: var(--text-ink);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.back-pill {
  background: var(--bg-Warm);
  color: var(--accent-orange);
}

.theme-pill:hover,
.back-pill:hover {
  border-color: var(--accent-orange);
  background: var(--accent-orange);
  color: #FFFFFF;
}

/* Main Shell & Editorial Warm Sidebar */
.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: calc(100vh - 90px);
}

.sidebar {
  background: var(--bg-Warm);
  color: var(--text-ink);
  border-right: 1px solid var(--line-hair);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.side-caption {
  color: var(--text-muted);
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line-hair);
  margin-bottom: 6px;
}

.sidebar nav {
  display: grid;
  gap: 5px;
}

.sidebar button {
  position: relative;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-ink);
  text-align: left;
  padding: 10px 14px;
  border-radius: 0;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  transition: all 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.sidebar button:hover {
  background: var(--bg-surface);
  border-color: var(--line-hair);
  color: var(--accent-orange);
  padding-left: 18px;
}

.sidebar button[aria-current="page"] {
  background: var(--bg-surface);
  border-color: var(--line-hair);
  border-left: 3.5px solid var(--accent-orange);
  color: var(--accent-orange);
  font-weight: 800;
  padding-left: 16px;
}

.sidebar .side-install-link {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-surface);
  color: var(--text-strong);
  border: 1px solid var(--line-hair);
  border-left: 3px solid var(--accent-orange);
  font-size: 13px;
  transition: all 0.22s ease;
}

.sidebar .side-install-link small {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--accent-orange);
  margin-bottom: 2px;
}

.sidebar .side-install-link strong {
  font-size: 0.82rem;
  font-weight: 700;
}

.sidebar .side-install-link span {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line-hair);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-orange);
  font-weight: 700;
  transition: all 0.22s ease;
}

.sidebar .side-install-link:hover {
  border-color: var(--accent-orange);
  background: var(--accent-orange-soft);
}

.sidebar .side-install-link:hover span {
  background: var(--accent-orange);
  border-color: var(--accent-orange);
  color: #FFFFFF;
  transform: translateX(2px);
}

.side-footer {
  margin-top: auto;
  color: var(--text-muted);
  padding: 20px 12px 0;
  border-top: 1px solid var(--line-hair);
}

/* Workspace & Search Header */
.workspace {
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 36px 72px;
}

.workspace-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  border-bottom: 1px solid var(--line-hair);
  padding-bottom: 20px;
}

.eyebrow {
  color: var(--accent-orange);
  margin: 0 0 6px;
}

.heading-lockup {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
}

.las-display-en {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: clamp(1.5rem, 2.2vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text-strong);
}

h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1.3;
  margin: 0;
}

h2 {
  margin: 0;
}

.search {
  height: 40px;
  border: 1px solid var(--line-hair);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  width: min(340px, 100%);
  border-radius: 999px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search:focus-within {
  border-color: var(--accent-orange);
  box-shadow: 0 0 0 3px rgba(234, 85, 4, 0.12);
}

.search span {
  font-size: 20px;
  line-height: 1;
  color: var(--accent-orange);
}

.search input {
  border: 0;
  outline: 0;
  width: 100%;
  min-width: 0;
  background: transparent;
  color: var(--text-strong);
  font-size: 13.5px;
}

.status {
  padding: 36px 0;
  color: var(--text-muted);
}

.results {
  padding-top: 18px;
}

.section-title {
  font-family: "IBM Plex Mono", "Noto Sans TC", sans-serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-strong);
  margin: 18px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-hair);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title span {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg-Warm);
  border: 1px solid var(--line-hair);
  color: var(--accent-orange);
}

/* Video & Article Curated Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.item {
  position: relative;
  border: 1px solid var(--line-hair);
  border-top: 3px solid var(--line-strong);
  background: var(--bg-surface);
  text-align: left;
  padding: 0;
  border-radius: 0;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  min-height: 224px;
  transition: border-color 0.25s cubic-bezier(0.22, 1, 0.36, 1),
              background-color 0.25s ease,
              transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.item:hover {
  border-color: var(--accent-orange);
  border-top-color: var(--accent-orange);
  background: var(--bg-Warm);
  transform: translateY(-2px);
}

.thumb {
  height: auto;
  aspect-ratio: 3 / 1;
  background: #1B1B19;
  color: #FEFCF7;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 14px 16px;
  position: relative;
  border-bottom: 1px solid var(--line-hair);
}

.thumb:before {
  content: none;
}

.thumb-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 1;
}

.thumb.article {
  background: var(--bg-Warm);
  color: var(--text-strong);
}

.item-body {
  padding: 15px 17px 17px;
  display: grid;
  gap: 7px;
  flex: 1;
  align-content: start;
}

.item-meta {
  font-family: "IBM Plex Mono", "Noto Sans TC", monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--accent-orange);
  font-weight: 700;
}

.item-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-strong);
  line-height: 1.4;
  display: inline;
  background-image: linear-gradient(var(--accent-orange), var(--accent-orange));
  background-size: 0% 1.5px;
  background-repeat: no-repeat;
  background-position: left bottom;
  transition: background-size 0.32s cubic-bezier(0.22, 1, 0.36, 1), color 0.22s ease;
}

.item:hover .item-title {
  color: var(--accent-orange);
  background-size: 100% 1.5px;
}

.item-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
}

/* Video Modal Viewer */
.viewer {
  border: 1px solid var(--line-hair);
  border-top: 3px solid var(--accent-orange);
  border-radius: 0;
  width: min(920px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  background: var(--bg-surface);
  color: var(--text-ink);
  box-shadow: 0 22px 68px rgba(0, 0, 0, 0.32);
}

.viewer::backdrop {
  background: rgba(15, 15, 14, 0.62);
  backdrop-filter: blur(6px);
}

.viewer-head {
  background: var(--bg-Warm);
  color: var(--text-strong);
  border-bottom: 1px solid var(--line-hair);
  padding: 16px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.viewer-head h2 {
  font-size: 19px;
  font-weight: 800;
}

.viewer-head button {
  background: var(--bg-surface);
  color: var(--text-ink);
  border: 1px solid var(--line-hair);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.viewer-head button:hover {
  border-color: var(--accent-orange);
  background: var(--accent-orange);
  color: #FFFFFF;
}

.viewer #viewerBody {
  padding: 22px;
  overflow: auto;
  max-height: calc(100vh - 115px);
}

.viewer video {
  display: block;
  width: 100%;
  max-height: 65vh;
  background: #000;
  border: 1px solid var(--line-hair);
}

.viewer p {
  line-height: 1.75;
}

.viewer .video-info {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--bg-Warm);
  border-left: 3px solid var(--accent-orange);
  font-size: 13.5px;
  color: var(--text-ink);
}

.load-error {
  padding: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--line-hair);
  border-left: 3.5px solid var(--accent-orange);
}

.load-error a {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent-orange);
  font-weight: 700;
  text-decoration: underline;
}

/* Option A Dual-Ring Inertia Cursor */
@media (pointer: fine) and (hover: hover) {
  body.las-cursor-enabled:not(:has(dialog[open])),
  body.las-cursor-enabled:not(:has(dialog[open])) button,
  body.las-cursor-enabled:not(:has(dialog[open])) a,
  body.las-cursor-enabled:not(:has(dialog[open])) .item {
    cursor: none !important;
  }
  body.las-cursor-enabled input {
    cursor: text !important;
  }
  .las-cursor-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 99999;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
  }
  .las-cursor-layer.is-active { opacity: 1; }
  .las-cursor-layer.is-suppressed .las-cursor-dot,
  .las-cursor-layer.is-suppressed .las-cursor-ring { opacity: 0; }
  .las-cursor-dot {
    position: fixed;
    top: 0;
    left: 0;
    width: 7px;
    height: 7px;
    margin-left: -3.5px;
    margin-top: -3.5px;
    border-radius: 999px;
    background: var(--accent-orange);
    pointer-events: none;
  }
  .las-cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    width: 32px;
    height: 32px;
    margin-left: -16px;
    margin-top: -16px;
    border-radius: 999px;
    border: 1.2px solid var(--accent-orange);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.24s cubic-bezier(0.22, 1, 0.36, 1),
                height 0.24s cubic-bezier(0.22, 1, 0.36, 1),
                margin 0.24s cubic-bezier(0.22, 1, 0.36, 1),
                background-color 0.22s ease,
                border-color 0.22s ease;
  }
  .las-cursor-label {
    font-family: "IBM Plex Mono", monospace;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #FFFFFF;
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.2s ease, transform 0.2s ease;
  }
  .las-cursor-ring.is-hover-card {
    width: 56px;
    height: 56px;
    margin-left: -28px;
    margin-top: -28px;
    background-color: var(--accent-orange);
    border-color: var(--accent-orange);
    box-shadow: 0 6px 20px rgba(234, 85, 4, 0.3);
  }
  .las-cursor-ring.is-hover-card .las-cursor-label {
    opacity: 1;
    transform: scale(1);
  }
  .las-cursor-ring.is-hover-card ~ .las-cursor-dot {
    opacity: 0 !important;
  }
  .las-cursor-ring.is-hover-btn {
    width: 44px;
    height: 44px;
    margin-left: -22px;
    margin-top: -22px;
    background-color: rgba(234, 85, 4, 0.14);
    border-color: var(--accent-orange);
  }
}

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { padding: 24px 20px; }
}

@media (max-width: 650px) {
  .las-marquee-bar { display: none; }
  .topbar { padding: 10px 14px; }
  .brand-logo { width: 96px; height: 28px; }
  .brand small { display: none; }
  .topbar-right #accountName { display: none; }
  .shell { display: block; }
  .sidebar { padding: 10px 12px; min-height: 0; border-right: 0; border-bottom: 1px solid var(--line-hair); }
  .side-caption, .side-footer { display: none; }
  .sidebar nav { display: flex; overflow-x: auto; gap: 6px; }
  .sidebar button { white-space: nowrap; padding: 8px 12px; font-size: 12px; border-radius: 999px; border: 1px solid var(--line-hair); background: var(--bg-surface); }
  .sidebar button[aria-current="page"] { background: var(--accent-orange); color: #FFFFFF; border-color: var(--accent-orange); padding-left: 12px; }
  .sidebar .side-install-link { margin-top: 8px; padding: 9px 12px; }
  .workspace { padding: 20px 14px 56px; }
  .workspace-head { display: grid; gap: 14px; }
  .search { width: 100%; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .item { min-height: 0; }
  .viewer #viewerBody { padding: 14px; }
  .viewer-head { padding: 14px; }
}
