/* Loomsday — Monochrome Obsidian / Paper Design System (light-dark()) */

:root {
  color-scheme: light dark;
  --bg: light-dark(#f8f8f7, #0e0e0e);
  --surface: light-dark(#ffffff, #141416);
  --surface-alt: light-dark(#f2f2f0, #1a1a1d);
  --border: light-dark(#e2e2e0, #26262a);
  --border-strong: light-dark(#cfcfcc, #3a3a40);
  --text: light-dark(#111113, #f5f5f7);
  --muted: light-dark(#58585f, #9c9ca6);
  --subtle: light-dark(#767680, #767681);
  --btn-primary-bg: light-dark(#111113, #f5f5f7);
  --btn-primary-fg: light-dark(#fafafa, #0e0e0e);
  --shadow: light-dark(0 12px 32px rgba(0, 0, 0, 0.08), 0 18px 44px rgba(0, 0, 0, 0.55));
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

:root[data-theme="light"] {
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
  overflow-x: clip;
}

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

button,
input {
  font: inherit;
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 24px;
}

.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
}

.topbar-inner {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.brand-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 999px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, opacity 0.14s ease;
}

.btn-sm {
  height: 30px;
  padding: 0 11px;
  font-size: 12px;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--border-strong);
  background: var(--surface-alt);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-alt);
}

/* Main */
.main-shell {
  padding-top: 48px;
  padding-bottom: 64px;
  display: flex;
  flex-direction: column;
  gap: 44px;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Hero + Launcher */
.hero {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 820px;
}

.hero-title {
  margin: 0;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.035em;
}

.hero-title span {
  color: var(--muted);
}

.hero-sub {
  margin: 0;
  font-size: 16px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 660px;
}

.launcher-bar {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.launcher-bar:focus-within {
  border-color: var(--border-strong);
}

.launcher-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 8px;
}

.launcher-search-icon {
  color: var(--subtle);
}

.launcher-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 14px;
  height: 36px;
}

.launcher-input::placeholder {
  color: var(--subtle);
}

.launcher-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.detected-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 5px 9px;
  border-radius: 6px;
  white-space: nowrap;
}

.sample-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.sample-label {
  font-size: 12px;
  color: var(--subtle);
}

.sample-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.sample-chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-alt);
}

/* Directory Grid */
.directory-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.section-title {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.section-sub {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.count-pill {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.app-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.app-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-alt);
  transform: translateY(-1px);
}

.app-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.app-card-ident {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark-svg {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}

.app-card-name {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.app-card-skin {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--subtle);
  margin-top: 2px;
}

.app-card-cat {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.app-card-tagline {
  margin: 0;
  font-size: 14px;
  line-height: 1.48;
  color: var(--muted);
}

.app-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.app-card-origin {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-card-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

/* Skill Banner */
.skill-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.skill-banner-copy {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 660px;
}

.skill-banner-title {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.skill-banner-sub {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}

.skill-banner-sub code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
}

.skill-banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 20px 0 28px;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--subtle);
}

.footer-link {
  color: var(--muted);
}

.footer-link:hover {
  color: var(--text);
  text-decoration: underline;
}

/* Popover */
.dir-popover {
  margin: 0;
  position: fixed;
  top: 66px;
  right: 24px;
  left: auto;
  width: 224px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.popover-label {
  padding: 6px 10px 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtle);
}

.popover-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.popover-item:hover {
  background: var(--surface-alt);
}

.popover-item-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.popover-item-title {
  font-size: 13px;
  font-weight: 600;
}

.popover-item-sub {
  font-size: 11px;
  color: var(--muted);
}

.popover-check {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
}

.popover-item[aria-checked="true"] .popover-check {
  background: var(--text);
}

/* Dialog */
.dir-dialog {
  width: min(860px, calc(100vw - 28px));
  max-height: min(84vh, 760px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.dir-dialog[open] {
  display: flex;
  flex-direction: column;
}

.dir-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.dialog-title {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.dialog-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.skill-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  overflow-x: auto;
}

.skill-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.skill-tab:hover {
  color: var(--text);
}

.skill-tab[aria-selected="true"] {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.dialog-body {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  flex: 1;
}

.skill-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.mono-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 4px 9px;
  border-radius: 6px;
}

.skill-meta-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-viewer {
  margin: 0;
  padding: 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  overflow: auto;
  flex: 1;
  min-height: 220px;
  max-height: 460px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Toast */
.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 14px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
}

/* Responsive Mobile */
@media (max-width: 760px) {
  .container {
    padding: 0 16px;
  }

  .main-shell {
    padding-top: 28px;
    padding-bottom: 44px;
    gap: 32px;
  }

  .launcher-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
  }

  .launcher-field {
    padding-left: 4px;
  }

  .launcher-controls {
    justify-content: space-between;
  }

  .btn,
  .icon-btn {
    min-height: 40px;
  }

  .apps-grid {
    grid-template-columns: 1fr;
  }

  .skill-banner {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px;
  }

  .skill-banner-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .brand-badge {
    display: none;
  }
}
