@import url("https://cdn.jsdelivr.net/npm/geist@1.2.0/dist/fonts/geist-sans/style.css");
@import url("https://cdn.jsdelivr.net/npm/geist@1.2.0/dist/fonts/geist-mono/style.css");

/* 1. RESET & VARIABLES */
:root {
  /* Colors */
  --bg-main: #CCCCCC;
  --bg-modal: #FFFFFF;
  --bg-code: #F4F9F8;

  --text-base: #1A1A1A;
  --text-muted: #666666;
  --text-accent: #02887D;

  --border-color: #1A1A1A;
  --border-accent: #02887D;

  /* Typography */
  --font-sans: "Geist Sans", sans-serif;
  --font-mono: "Geist Mono", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scrollbar-gutter: stable;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  /* iOS Font Boosting Fix */
}

body {
  background-color: var(--bg-main);
  color: var(--text-base);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scrollbar Minimalist */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: #999;
  border-radius: 4px;
  border: 2px solid var(--bg-main);
}

::-webkit-scrollbar-thumb:hover {
  background-color: #666;
}

/* 2. UTILITY CLASSES */

/* Colors */
.u-text-main {
  color: var(--text-base);
}

.u-text-muted {
  color: var(--text-muted);
}

.u-text-accent {
  color: var(--text-accent);
}

.u-bg-code {
  background-color: var(--bg-code);
}

/* Typography */
.u-text-48 {
  font-size: 48px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 400;
}

.u-text-28 {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.u-text-20 {
  font-size: 20px;
  line-height: 1.4;
}

.u-text-16 {
  font-size: 16px;
  line-height: 1.5;
}

.u-text-14 {
  font-size: 14px;
  line-height: 1.6;
}

.u-text-12 {
  font-size: 12px;
  line-height: 1.4;
}

.u-w-400 {
  font-weight: 400;
}

.u-w-500 {
  font-weight: 500;
}

.u-w-600 {
  font-weight: 600;
}

.u-mono {
  font-family: var(--font-mono);
}

/* Spacing */
.u-mb-8 {
  margin-bottom: 8px;
}

.u-mb-12 {
  margin-bottom: 12px;
}

.u-mb-16 {
  margin-bottom: 16px;
}

.u-mb-24 {
  margin-bottom: 24px;
}

.u-mb-32 {
  margin-bottom: 32px;
}

.u-mb-64 {
  margin-bottom: 64px;
}

.u-mt-32 {
  margin-top: 32px;
}


/* 3. LAYOUT STRUCTURE */

/* Main Wrapper */
.page-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 64px 32px;
  width: 100%;
}

/* Header */
.site-header {
  margin-bottom: 64px;
}

/* 2-Column Grid */
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 760px) 360px;
  gap: 80px;
  align-items: start;
}

/* Responsive Grid */
@media (max-width: 900px) {
  .content-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 64px;
  }
}

@media (max-width: 800px) {
  .page-wrapper {
    padding: 24px 16px;
  }

  .content-grid {
    gap: 48px;
  }

  .sidebar-col {
    margin-top: 64px;
  }
}

@media (max-width: 500px) {
  .content-grid {
    gap: 32px;
  }

  .sidebar-col {
    order: 2;
    margin-top: 64px;
  }
}

/* 4. COMPONENTS */

/* Hero */
.hero-block h1 {
  font-weight: 400 !important;
}

/* Link spacing */
footer div {
  line-height: 1.4;
}

/* Search */
.search-wrapper {
  position: relative;
  width: 100%;
  margin-bottom: 32px;
}

.search-input {
  width: 100%;
  background: #C2C2C2;
  /* Updated Background */
  border: 1px solid var(--border-color);
  padding: 12px 16px 12px 16px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-base);
  border-radius: 0;
  outline: none;
}

.search-input:focus {
  border-color: var(--text-accent);
}

.search-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  /* pointer-events handled by JS */
}

/* Utilities */
.u-text-right {
  text-align: right;
}

@media (max-width: 800px) {
  .u-text-right {
    text-align: left;
  }
}

/* Filters */
.filters-list {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 48px;
  list-style: none;
}

.filter-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-base);
  position: relative;
  overflow: hidden;
  /* transition: color 0.2s;  Removed color transition to focus on underline */
}

/* Right-to-Left Underline Animation on Hover */
.filter-btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  height: 1px;
  background-color: var(--text-base);
  transition: width 0.3s ease;
}

.filter-btn:hover::after {
  width: 100%;
  left: 0;
  /* Anchor left to fill */
}

/* Active State */
.filter-btn.active {
  color: var(--text-accent);
}

.filter-btn.active::after {
  background-color: var(--text-accent);
  width: 100%;
  left: 0;
}


/* Script List (Row) */
.script-row {
  display: flex;
  flex-direction: column;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 32px;
  min-width: 0;
}

.script-number {
  color: var(--text-base);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}

.script-info-row {
  display: flex;
  align-items: baseline;
  margin-bottom: 16px;
  min-width: 0;
}

.script-title {
  font-size: 24px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.script-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-left: 32px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 1;
  min-width: 0;
}

/* Mobile/Tablet Stack (< 800px) */
@media (max-width: 800px) {
  .script-title {
    font-size: 18px;
    flex-shrink: 1;
    /* Allow shrinking if very narrow */
    white-space: normal;
    /* Allow wrapping if title is very long */
  }

  .script-info-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .script-desc {
    margin-left: 0;
    margin-top: 4px;
    width: 100%;

    /* 2 lines limit with ellipsis */
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    /* Standard property */
    -webkit-box-orient: vertical;
  }
}

.script-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.action-link {
  font-size: 14px;
  font-weight: 500;
  text-decoration: underline;
  color: var(--text-muted);
  cursor: pointer;
}

.action-link.download {
  color: var(--text-accent);
}

.action-link:hover {
  text-decoration: underline;
  /* Keep underline on hover */
  opacity: 0.8;
}

/* Scroll Lock */
.no-scroll {
  overflow: hidden !important;
  height: 100vh !important;
  touch-action: none;
  /* Mobile fix */
}

/* 5. MODAL */
.modal-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(204, 204, 204, 0.85);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-window {
  background: var(--bg-modal);
  width: min(860px, calc(100% - 32px));
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

/* Mobile Modal Full Width */
@media (max-width: 500px) {
  .modal-window {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .modal-overlay {
    align-items: flex-end;
    /* Or center */
  }
}

.modal-header {
  padding: 24px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background-color: #C2C2C2;
  /* Requested Color */
}

.modal-body {
  padding: 32px;
  overflow-y: auto;
}

.modal-body-content {
  max-width: 720px;
  margin: 0 auto;
}

/* Docs Specific Styles (Markdown) */
.md-content h1 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text-base);
}

.md-content h2 {
  font-size: 20px;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 16px;
}

.md-content h3 {
  font-size: 16px;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 12px;
}

.md-content h4 {
  font-size: 14px;
  font-weight: 600;
  margin-top: 16px;
  margin-bottom: 8px;
}

.md-content p {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 12px;
  color: var(--text-base);
}

.md-content ul,
.md-content ol {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 12px;
  padding-left: 20px;
}

.md-content li {
  margin-bottom: 6px;
}

.md-content a {
  color: var(--text-accent);
  text-decoration: underline;
  font-weight: 500;
}

.md-content hr {
  border: none;
  border-top: 1px solid var(--border-accent);
  margin: 32px 0;
}

.md-content blockquote {
  font-size: 14px;
  padding-left: 16px;
  border-left: 3px solid var(--border-accent);
  color: #333;
  margin: 16px 0;
  font-style: italic;
  background-color: transparent;
}

.md-content code {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 2px 4px;
  background: var(--bg-code);
  border: 1px solid var(--border-accent);
  color: var(--text-base);
}

.md-content pre {
  background: var(--bg-code);
  border: 1px solid var(--border-accent);
  padding: 16px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.md-content pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
  font-size: 13px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}