/* ── Reset & Base ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --text: #6b6375;
  --text-h: #08060d;
  --bg: #fff;
  --border: #e5e4e7;
  --code-bg: #f4f3ec;
  --accent: #aa3bff;
  --accent-bg: rgba(170, 59, 255, 0.1);
  --accent-border: rgba(170, 59, 255, 0.5);
  --social-bg: rgba(244, 243, 236, 0.5);
  --shadow:
    rgba(0, 0, 0, 0.1) 0 10px 15px -3px,
    rgba(0, 0, 0, 0.05) 0 4px 6px -2px;

  --sans: system-ui, 'Segoe UI', Roboto, sans-serif;
  --heading: system-ui, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #9ca3af;
    --text-h: #f3f4f6;
    --bg: #16171d;
    --border: #2e303a;
    --code-bg: #1f2028;
    --accent: #c084fc;
    --accent-bg: rgba(192, 132, 252, 0.15);
    --accent-border: rgba(192, 132, 252, 0.5);
    --social-bg: rgba(47, 48, 58, 0.5);
    --shadow:
      rgba(0, 0, 0, 0.4) 0 10px 15px -3px,
      rgba(0, 0, 0, 0.25) 0 4px 6px -2px;
  }
}

html {
  font: 18px/145% var(--sans);
  letter-spacing: 0.18px;
  color-scheme: light dark;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

@media (max-width: 1024px) {
  html { font-size: 16px; }
}

body {
  min-height: 100vh;
}

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

img {
  display: block;
  max-width: 100%;
}

h1 {
  font-family: var(--heading);
  font-size: 42px;
  font-weight: 500;
  letter-spacing: -1.28px;
  color: var(--text-h);
  margin: 0;
}

h2 {
  font-family: var(--heading);
  font-size: 20px;
  font-weight: 500;
  line-height: 120%;
  letter-spacing: -0.24px;
  color: var(--text-h);
  margin: 0;
}

h3 {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-h);
  margin: 0;
}

p {
  margin: 0;
}

time {
  font-size: 12px;
  color: var(--text);
  opacity: 0.7;
}

::selection {
  background: var(--accent-bg);
  color: var(--text-h);
}

/* ── Layout ── */
.nav-inner {
  max-width: 1126px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.main {
  max-width: 1126px;
  width: 100%;
  margin: 0 auto;
  padding: 7px 24px;
  box-sizing: border-box;
  flex: 1;
}

/* ── Navigation ── */
.nav {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.nav-logo {
  font-family: var(--heading);
  font-size: 22px;
  font-weight: 500;
  color: var(--text-h);
  letter-spacing: -0.5px;
}

.nav-logo span {
  color: var(--accent);
}

.nav-logo .cursor {
  animation: cursor-blink 1s step-end infinite;
  color: var(--text-h);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  font-size: 15px;
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.2s;
}

.nav-link:hover {
  color: var(--text-h);
  background: var(--social-bg);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-bg);
}

.lang-toggle {
  background: var(--social-bg);
  border: 1px solid var(--border);
  color: var(--text-h);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--mono);
  padding: 5px 10px;
  border-radius: 6px;
  margin-left: 8px;
  transition: all 0.2s;
}

.lang-toggle:hover {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent);
}

/* ── Hero ── */
.hero {
  text-align: center;
  padding: 48px 0;
}

.subtitle {
  font-size: 18px;
  color: var(--text);
  max-width: 540px;
  margin: 12px auto 0;
}

/* ── Home Grid ── */
.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  text-align: left;
}

.home-card {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
}

.home-card h2 {
  margin-bottom: 20px;
}

.home-post {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.home-post:last-of-type {
  border-bottom: none;
}

.home-post h3 {
  margin-bottom: 6px;
}

.home-post p {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.home-post time {
  font-size: 12px;
  opacity: 0.7;
  display: block;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  margin-top: 8px;
  font-family: var(--sans);
  transition: opacity 0.2s;
}

.link-btn:hover {
  opacity: 0.75;
}

.home-gallery-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.home-gallery-preview img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.home-gallery-preview video {
  width: 100%;
  height: 100px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #000;
}

/* ── Blog ── */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  padding-top: 20px;
}

.blog-card {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: left;
  transition: box-shadow 0.2s;
}

.blog-card:hover {
  box-shadow: var(--shadow);
}

.blog-card h2 {
  margin: 8px 0 10px;
}

.blog-card p {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.read-more-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  font-family: var(--sans);
  transition: opacity 0.2s;
}

.read-more-btn:hover {
  opacity: 0.75;
}

/* ── Full Article ── */
.back-btn {
  display: inline-block;
  color: var(--text);
  font-size: 14px;
  padding: 4px 0;
  margin-bottom: 16px;
  font-family: var(--sans);
  transition: color 0.2s;
}

.back-btn:hover {
  color: var(--text-h);
}

.full-article {
  max-width: 720px;
  margin: 0 auto;
  text-align: left;
}

.full-article time {
  font-size: 13px;
}

.full-article h1 {
  margin: 12px 0 20px;
}

.full-article p {
  font-size: 16px;
  line-height: 170%;
  margin-bottom: 16px;
}

/* ── Article Content ── */
.article-content {
  text-align: left;
}

.article-content h2 {
  font-size: 22px;
  margin: 32px 0 12px;
  color: var(--text-h);
}

.article-content h3 {
  font-size: 18px;
  margin: 24px 0 8px;
  color: var(--text-h);
}

.article-content strong {
  color: var(--text-h);
}

.article-content ul,
.article-content ol {
  padding-left: 24px;
  margin: 12px 0 16px;
}

.article-content li {
  margin-bottom: 6px;
}

.article-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(170, 59, 255, 0.3);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s;
}

.article-content a:hover {
  text-decoration-color: var(--accent);
}

.article-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

/* Code blocks */
.article-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  margin: 16px 0 20px;
}

.article-content pre code {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 160%;
  color: var(--text-h);
  display: block;
  padding: 16px 0 16px 20px;
  background: none;
  border: none;
  border-radius: 0;
  counter-reset: line;
}

.article-content pre code .line {
  counter-increment: line;
  white-space: pre;
  min-height: 1.6em;
}

.article-content pre code .line::before {
  content: counter(line);
  position: sticky;
  left: 0;
  width: 40px;
  text-align: right;
  padding-right: 12px;
  margin-right: 8px;
  color: var(--text);
  opacity: 0.35;
  border-right: 1px solid var(--border);
  font-size: 13px;
  pointer-events: none;
  vertical-align: top;
}

.article-content pre code .line:nth-child(even) {
  background: rgba(0, 0, 0, 0.025);
}

@media (prefers-color-scheme: dark) {
  .article-content pre code .line:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
  }
}

.article-content pre code .line:hover {
  background: var(--accent-bg);
}

.article-content code:not(pre code) {
  font-family: var(--mono);
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--code-bg);
  color: var(--accent);
  border: 1px solid var(--border);
}

/* Article images */
.article-image {
  margin: 24px 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.article-image img {
  width: 100%;
  height: auto;
  display: block;
}

.article-image-caption {
  font-size: 13px;
  color: var(--text);
  opacity: 0.8;
  padding: 10px 16px;
  text-align: center;
  margin: 0;
}

/* ── Gallery ── */
.gallery-container {
  max-width: 960px;
  margin: 20px auto 0;
}

.gallery-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gallery-viewer {
  flex: 1;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 3 / 2;
  background: var(--code-bg);
}

.gallery-viewer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#gallery-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

#gallery-video source {
  width: 100%;
  height: 100%;
}

.gallery-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 40%, rgba(0, 0, 0, 0.55));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.25s;
}

.gallery-viewer:hover .gallery-overlay,
.gallery-overlay.visible {
  opacity: 1;
}

.gallery-counter {
  color: #fff;
  font-size: 14px;
  font-family: var(--mono);
}

.gallery-actions {
  display: flex;
  justify-content: flex-end;
}

.gallery-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  font-family: var(--sans);
}

.gallery-action-btn:hover {
  background: rgba(0, 0, 0, 0.65);
}

.fullscreen-hint {
  font-size: 11px;
  opacity: 0.7;
  margin-left: 4px;
}

.fullscreen-hint.hidden {
  display: none;
}

.gallery-nav-btn {
  background: var(--social-bg);
  border: 1px solid var(--border);
  color: var(--text-h);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.gallery-nav-btn:hover {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent);
}

.gallery-caption {
  text-align: center;
  padding: 8px 0 0;
  font-size: 13px;
  color: var(--text, #555);
  font-family: var(--sans, system-ui, sans-serif);
  min-height: 1.4em;
}

.gallery-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.thumb {
  background: none;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s;
  flex-shrink: 0;
}

.thumb.active {
  border-color: var(--accent);
}

.thumb:hover {
  border-color: var(--accent-border);
}

.thumb img {
  width: 100px;
  height: 66px;
  object-fit: cover;
  display: block;
}

.thumb video {
  width: 100px;
  height: 66px;
  object-fit: contain;
  display: block;
  background: #000;
}

/* ── Programs Table ── */
.links-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  text-align: left;
  font-size: 15px;
}

.links-table th {
  font-weight: 500;
  color: var(--text-h);
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.links-table th:nth-child(1) { width: 25%; }
.links-table th:nth-child(2) { width: 75%; }

.links-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}

.links-table tr:hover td {
  background: var(--social-bg);
}

.table-link {
  color: var(--text-h);
  font-weight: 500;
  transition: color 0.2s;
}

.table-link:hover {
  color: var(--accent);
}

.table-url {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-size: 14px;
  transition: opacity 0.2s;
}

.table-url:hover {
  opacity: 0.75;
}

/* ── File Links ── */
.file-link {
  display: flex;
  align-items: center;
  margin: 12px 0 12px;
  gap: 0;
}

.file-link-inner {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex: 1;
  padding: 10px 14px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 6px 0 0 6px;
  color: var(--text-h);
  font-size: 14px;
  font-family: var(--mono);
  text-decoration: none;
  transition: color 0.2s;
  min-width: 0;
}

.file-link-inner:hover {
  color: var(--accent);
}

.file-name {
  font-weight: 600;
}

.file-size,
.file-hash {
  font-size: 12px;
  font-family: var(--mono);
  opacity: 0.6;
  white-space: nowrap;
}

.file-hash::before {
  content: 'SHA: ';
}

.file-download {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 48px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-left: none;
  border-radius: 0 6px 6px 0;
  color: var(--accent);
  font-size: 18px;
  text-decoration: none;
  transition: opacity 0.2s;
}

.file-download:hover {
  opacity: 0.7;
}

.file-link.missing .file-link-inner {
  color: var(--text);
  opacity: 0.5;
  font-style: italic;
  font-weight: 400;
}

@media (max-width: 768px) {
  .file-size,
  .file-hash {
    font-size: 11px;
  }
}

/* ── Guestbook ── */
.guestbook-subtitle {
  font-size: 16px;
  color: var(--text);
  margin: 8px 0 24px;
}

.gb-success {
  background: #d5f5e3;
  color: #27ae60;
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
}

.gb-error {
  background: #fadbd8;
  color: #c0392b;
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
}

.gb-form {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}

.gb-form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.gb-form-row input,
.gb-form-row textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text-h);
}

.gb-form-row input::placeholder,
.gb-form-row textarea::placeholder {
  color: var(--text);
  opacity: 0.6;
}

.gb-submit {
  padding: 10px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
}

.gb-submit:hover {
  opacity: 0.9;
}

.gb-entries {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.gb-empty {
  text-align: center;
  color: var(--text);
  padding: 32px;
  opacity: 0.7;
}

.gb-entry {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.gb-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.gb-entry-header strong {
  color: var(--text-h);
}

.gb-entry-header time {
  font-size: 12px;
  opacity: 0.7;
}

.gb-entry-message {
  font-size: 15px;
  line-height: 160%;
  white-space: pre-wrap;
}

.gb-replies {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gb-reply {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.gb-reply-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.gb-admin-badge {
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.gb-reply-message {
  font-size: 14px;
  line-height: 160%;
  white-space: pre-wrap;
}

.gb-reply-form {
  margin-top: 12px;
}

.gb-reply-input {
  display: flex;
  gap: 8px;
}

.gb-reply-input input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text-h);
}

.gb-reply-btn {
  padding: 8px 16px;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.gb-reply-btn:hover {
  background: var(--accent);
  color: #fff;
}

.gb-delete-form {
  display: inline;
  margin-top: 8px;
}

.gb-delete-btn {
  padding: 4px 12px;
  background: none;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.gb-delete-btn:hover {
  opacity: 1;
  color: #c0392b;
  border-color: #c0392b;
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 24px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  opacity: 0.6;
}

/* ── YT Downloader ── */
.yt-page h1 {
  margin-bottom: 8px;
}

.yt-subtitle {
  color: var(--text);
  margin-bottom: 24px;
}

.yt-container {
  max-width: 600px;
}

.yt-input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.yt-input-group input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: var(--bg-h);
  color: var(--text-h);
}

.yt-input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.yt-status {
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-h);
}

.yt-progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}

.yt-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.yt-progress-label {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 12px;
}

.yt-log {
  max-height: 200px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--text);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  line-height: 1.6;
}

.yt-log div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.yt-dl-btn {
  background: var(--success);
  color: #fff;
  border: none;
}

.yt-error {
  color: #e74c3c;
  margin-top: 12px;
  font-weight: 500;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .nav-inner {
    flex-direction: column;
    gap: 12px;
    padding: 16px;
  }

  .nav-links {
    flex-wrap: wrap;
    justify-content: center;
  }

  h1 { font-size: 32px; }

  .main { padding: 0 16px; }

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

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

  .gallery-nav-btn {
    width: 34px;
    height: 34px;
  }

  .links-table th:nth-child(2) {
    display: none;
  }

  .links-table td:nth-child(2) {
    display: none;
  }

  .links-table th,
  .links-table td {
    padding: 10px 8px;
  }

  .home-gallery-preview img,
  .home-gallery-preview video {
    height: 80px;
  }

  .gb-form-row {
    flex-direction: column;
    gap: 8px;
  }

  .gb-reply-input {
    flex-direction: column;
  }
}
