/* ======================================================
   STUDIO505 — Tools-specific CSS
   Complements style.css
   ====================================================== */

/* ===========================
   TAB BAR (replaces old header)
   =========================== */
.tools-tab-bar {
  position: sticky;
  top: 52px; /* below the site nav */
  z-index: 50;
  background: var(--ink);
  border-bottom: 2px solid rgba(241,240,234,.1);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tools-tab-bar::-webkit-scrollbar { display: none; }

.tools-tab-bar-inner {
  display: flex;
  min-width: max-content;
  padding: 0 8px;
}

.tools-tab-btn {
  font-family: 'Space Mono', monospace;
  font-size: .65rem;
  letter-spacing: .12em;
  color: rgba(241,240,234,.45);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 14px 18px;
  cursor: pointer;
  white-space: nowrap;
  text-transform: uppercase;
  transition: color .12s, border-color .12s;
}

.tools-tab-btn:hover {
  color: rgba(241,240,234,.85);
  border-bottom-color: rgba(241,240,234,.25);
}

.tools-tab-btn[aria-selected="true"] {
  color: var(--paper);
  border-bottom-color: var(--red);
}

/* ===========================
   SPLASH SCREEN
   =========================== */
.tools-splash {
  min-height: calc(100vh - 104px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--paper);
  text-align: center;
  padding: 40px;
}

.tools-splash-label {
  font-family: 'Space Mono', monospace;
  font-size: .65rem;
  letter-spacing: .2em;
  color: rgba(241,240,234,.3);
  margin-bottom: 16px;
  text-transform: uppercase;
}

.tools-splash-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(4rem, 14vw, 10rem);
  line-height: .88;
  letter-spacing: -.05em;
  text-transform: uppercase;
  margin-bottom: 28px;
}

.tools-splash-sub {
  font-family: 'Space Mono', monospace;
  font-size: .8rem;
  letter-spacing: .05em;
  color: rgba(241,240,234,.45);
  max-width: 480px;
  line-height: 1.7;
  margin: 0 auto 20px;
}

.tools-splash-hint {
  font-family: 'Space Mono', monospace;
  font-size: .72rem;
  letter-spacing: .15em;
  color: var(--red);
  animation: hintPulse 2s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { opacity: .7; }
  50% { opacity: 1; }
}

/* ===========================
   TOOL PANELS (single view)
   =========================== */
.tool-panel {
  min-height: calc(100vh - 104px);
  padding: 64px 40px;
  animation: panelIn .2s ease;
}

.tool-panel--dark {
  background: #111;
  color: var(--paper);
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Hide tools-splash when a tool is shown */
.tools-splash.hidden { display: none; }


/* ===========================
   TOOLS HEADER
   =========================== */
.tools-header {
  padding: 100px 40px 64px;
  margin-top: 52px;
  border-bottom: var(--border);
  background: var(--ink);
  color: var(--paper);
  position: relative;
  overflow: hidden;
}

.tools-header::after {
  content: 'TOOLS';
  position: absolute;
  right: -0.05em;
  bottom: -0.2em;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(8rem, 20vw, 16rem);
  letter-spacing: -.05em;
  text-transform: uppercase;
  color: rgba(241,240,234,.04);
  pointer-events: none;
  line-height: 1;
  user-select: none;
}

.tools-header-inner { max-width: 1200px; position: relative; z-index: 1; }

.tools-header-label {
  font-family: 'Space Mono', monospace;
  font-size: .65rem;
  letter-spacing: .2em;
  color: rgba(241,240,234,.35);
  margin-bottom: 12px;
  text-transform: uppercase;
}

.tools-header-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(3.5rem, 11vw, 8rem);
  line-height: .88;
  letter-spacing: -.04em;
  text-transform: uppercase;
  margin-bottom: 28px;
}

.tools-header-sub {
  font-family: 'Space Mono', monospace;
  font-size: .75rem;
  letter-spacing: .06em;
  color: rgba(241,240,234,.45);
  line-height: 1.7;
  margin-bottom: 32px;
}

/* Jump nav */
.tools-jumps {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.tools-jump-btn {
  font-family: 'Space Mono', monospace;
  font-size: .7rem;
  letter-spacing: .12em;
  color: rgba(241,240,234,.6);
  border: 1px solid rgba(241,240,234,.25);
  padding: 9px 18px;
  transition: background .12s, color .12s, border-color .12s, transform .08s;
  text-transform: uppercase;
}

.tools-jump-btn:hover {
  background: var(--red);
  border-color: var(--red);
  color: var(--paper);
  transform: translateY(-2px);
}

.tools-jump-btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ===========================
   TOOL SECTION SHARED
   =========================== */
.tool-section {
  padding: 96px 40px;
  border-bottom: var(--border);
  max-width: 100%;
  position: relative;
}

.tool-section--dark {
  background: #111;
  color: var(--paper);
}

/* Subtle left accent stripe on each section */
.tool-section::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: background .2s;
}
.tool-section:hover::before {
  background: var(--red);
}

.tool-section-head {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  margin-bottom: 60px;
  flex-wrap: wrap;
  padding-bottom: 40px;
  border-bottom: 1px solid rgba(128,128,128,.15);
}

.tool-section-num {
  font-family: 'Space Mono', monospace;
  font-size: .75rem;
  letter-spacing: .25em;
  color: var(--ink-light);
  flex-shrink: 0;
  padding-top: 8px;
  min-width: 28px;
}

.tool-section--dark .tool-section-num { color: rgba(241,240,234,.3); }

.tool-section-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.tool-section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  letter-spacing: -.04em;
  text-transform: uppercase;
  line-height: .95;
}

.tool-section-subtitle {
  font-family: 'Space Mono', monospace;
  font-size: .7rem;
  letter-spacing: .08em;
  color: var(--ink-light);
  margin-top: 8px;
  line-height: 1.7;
}

.tool-section--dark .tool-section-subtitle { color: rgba(241,240,234,.35); }
.tool-section-subtitle a { text-decoration: underline; }
.tool-section-subtitle a:hover { color: var(--red); }

.tool-section-tag {
  font-family: 'Space Mono', monospace;
  font-size: .58rem;
  letter-spacing: .2em;
  padding: 4px 10px;
  text-transform: uppercase;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 4px;
}

.tag--working { color: #00aa44; border: 1px solid #00aa44; }
.tag--soon    { color: var(--ink-light); border: 1px solid var(--ink-faint); }

/* ===========================
   SHARED FORM ELEMENTS
   =========================== */
.tool-label {
  display: block;
  font-family: 'Space Mono', monospace;
  font-size: .6rem;
  letter-spacing: .2em;
  color: var(--ink-light);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.tool-section--dark .tool-label { color: rgba(241,240,234,.35); }

.tool-input {
  width: 100%;
  font-family: 'Space Mono', monospace;
  font-size: .85rem;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  padding: 13px 16px;
  transition: border-color .1s;
  outline: none;
}

.tool-input:focus { border-color: var(--red); }
.tool-section--dark .tool-input {
  background: #1e1e1e;
  color: var(--paper);
  border-color: rgba(241,240,234,.2);
}

.tool-section--dark .tool-input:focus { border-color: var(--red); }

.cobalt-link { text-decoration: underline; color: inherit; }
.cobalt-link:hover { color: var(--red); }

/* ===========================
   YOUTUBE TOOL
   =========================== */
.yt-tool { max-width: 860px; }

.yt-url-row { margin-bottom: 28px; }

.yt-url-input-wrap {
  display: flex;
  gap: 0;
}

.yt-url-input {
  flex: 1;
  border-right: none;
  font-size: .9rem;
  letter-spacing: .02em;
}

.yt-paste-btn {
  font-family: 'Space Mono', monospace;
  font-size: .7rem;
  letter-spacing: .12em;
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--ink);
  padding: 0 20px;
  cursor: pointer;
  transition: background .08s, border-color .08s;
  white-space: nowrap;
}

.yt-paste-btn:hover { background: var(--red); border-color: var(--red); }
.yt-paste-btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* Options row */
.yt-options {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0;
  border: 2px solid var(--ink);
  margin-bottom: 24px;
}

.yt-fieldset {
  border: none;
  padding: 20px 24px;
  border-right: 2px solid var(--ink);
}

.yt-fieldset:last-child { border-right: none; }

.yt-fieldset legend { margin-bottom: 14px; }

.yt-radio-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.yt-radio-label {
  cursor: pointer;
}

.yt-radio-label input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.yt-radio-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: 'Space Mono', monospace;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--ink-mid);
  border: 2px solid var(--ink-faint);
  padding: 10px 16px;
  transition: background .08s, color .08s, border-color .08s;
  min-width: 72px;
  text-align: center;
}

.yt-radio-label input:checked + .yt-radio-btn {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.yt-radio-label:hover .yt-radio-btn {
  border-color: var(--red);
  color: var(--red);
}

.yt-radio-label input:checked:focus-visible + .yt-radio-btn {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.yt-radio-icon {
  font-size: 1rem;
  margin-bottom: 2px;
}

.yt-radio-sub {
  font-size: .55rem;
  letter-spacing: .1em;
  font-weight: 400;
  opacity: .65;
}

/* Download button */
.yt-action-row { margin-bottom: 20px; }

.yt-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: 'Space Mono', monospace;
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--paper);
  background: var(--ink);
  border: 2px solid var(--ink);
  padding: 16px 32px;
  cursor: pointer;
  transition: background .08s, border-color .08s, transform .05s;
  text-transform: uppercase;
}

.yt-download-btn:hover { background: var(--red); border-color: var(--red); }
.yt-download-btn:active { transform: scale(.98); }
.yt-download-btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.yt-download-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.yt-btn-icon { font-size: 1.2rem; line-height: 1; }

/* Loading animation */
.yt-download-btn.loading .yt-btn-icon {
  animation: spin 1s linear infinite;
  display: inline-block;
}

@keyframes spin {
  0% { transform: rotate(0); }
  100% { transform: rotate(360deg); }
}

/* Status */
.yt-status {
  font-family: 'Space Mono', monospace;
  font-size: .72rem;
  letter-spacing: .08em;
  line-height: 1.6;
  min-height: 20px;
  margin-bottom: 12px;
}

.yt-status.err { color: var(--red); }
.yt-status.ok  { color: #00aa44; }
.yt-status.info { color: var(--ink-light); }

/* Result */
.yt-result {
  border: 2px solid #00aa44;
  padding: 20px 24px;
  margin-bottom: 20px;
  background: rgba(0,170,68,.05);
}

.yt-result-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.yt-result-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.yt-result-icon {
  font-size: 1.2rem;
  color: #00aa44;
}

.yt-result-text {
  font-family: 'Space Mono', monospace;
  font-size: .75rem;
  letter-spacing: .06em;
  color: var(--ink);
}

.yt-result-link {
  font-family: 'Space Mono', monospace;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--paper);
  background: #00aa44;
  border: 2px solid #00aa44;
  padding: 10px 20px;
  transition: background .08s, border-color .08s;
  white-space: nowrap;
}

.yt-result-link:hover { background: #008833; border-color: #008833; }
.yt-result-link:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* Notice */
.yt-notice {
  font-family: 'Space Mono', monospace;
  font-size: .6rem;
  letter-spacing: .08em;
  color: var(--ink-light);
  line-height: 1.8;
  border-top: 1px solid var(--ink-faint);
  padding-top: 16px;
  margin-top: 8px;
}

.yt-notice a { text-decoration: underline; }
.yt-notice a:hover { color: var(--red); }

/* Quality / format note */
.yt-quality-note {
  font-family: 'Space Mono', monospace;
  font-size: .65rem;
  letter-spacing: .06em;
  line-height: 1.6;
  color: #cc7700;
  border: 1px solid #cc7700;
  padding: 8px 14px;
  margin-bottom: 12px;
  background: rgba(204, 119, 0, .06);
}

/* ===========================
   MARKDOWN VIEWER TOOL
   =========================== */
.md-tool { max-width: 1200px; }

/* Toolbar */
.md-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border: 2px solid rgba(241,240,234,.15);
  border-bottom: none;
  padding: 10px 16px;
  background: rgba(255,255,255,.04);
}

.md-toolbar-left, .md-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.md-tab-btn {
  font-family: 'Space Mono', monospace;
  font-size: .65rem;
  letter-spacing: .12em;
  color: rgba(241,240,234,.4);
  background: transparent;
  border: 1px solid rgba(241,240,234,.15);
  padding: 6px 14px;
  cursor: pointer;
  transition: background .08s, color .08s, border-color .08s;
  text-transform: uppercase;
}

.md-tab-btn:hover, .md-tab-btn--active {
  background: rgba(241,240,234,.12);
  color: var(--paper);
  border-color: rgba(241,240,234,.3);
}

.md-tab-btn--active { font-weight: 700; }
.md-tab-btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.md-file-label {
  font-family: 'Space Mono', monospace;
  font-size: .65rem;
  letter-spacing: .12em;
  color: rgba(241,240,234,.6);
  border: 1px solid rgba(241,240,234,.2);
  padding: 6px 14px;
  cursor: pointer;
  transition: background .08s, color .08s, border-color .08s;
  text-transform: uppercase;
}

.md-file-label:hover { background: var(--red); color: var(--paper); border-color: var(--red); }

.md-action-btn {
  font-family: 'Space Mono', monospace;
  font-size: .65rem;
  letter-spacing: .12em;
  color: rgba(241,240,234,.6);
  background: transparent;
  border: 1px solid rgba(241,240,234,.2);
  padding: 6px 14px;
  cursor: pointer;
  transition: background .08s, color .08s, border-color .08s;
  text-transform: uppercase;
}

.md-action-btn:hover { background: rgba(241,240,234,.12); color: var(--paper); border-color: rgba(241,240,234,.35); }
.md-action-btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.md-action-btn--ghost { color: rgba(241,240,234,.3); border-color: rgba(241,240,234,.1); }
.md-action-btn--ghost:hover { color: rgba(241,240,234,.6); }

/* For tools page -- dark variant in light section */
.tool-section:not(.tool-section--dark) .md-toolbar { border-color: var(--ink); background: rgba(17,17,17,.04); }
.tool-section:not(.tool-section--dark) .md-tab-btn { color: var(--ink-mid); border-color: var(--ink-faint); }
.tool-section:not(.tool-section--dark) .md-tab-btn:hover,
.tool-section:not(.tool-section--dark) .md-tab-btn--active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tool-section:not(.tool-section--dark) .md-file-label { color: var(--ink-mid); border-color: var(--ink-faint); }
.tool-section:not(.tool-section--dark) .md-file-label:hover { background: var(--red); color: var(--paper); border-color: var(--red); }
.tool-section:not(.tool-section--dark) .md-action-btn { color: var(--ink-mid); border-color: var(--ink-faint); }
.tool-section:not(.tool-section--dark) .md-action-btn:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tool-section:not(.tool-section--dark) .md-action-btn--ghost { color: var(--ink-light); }

/* Workspace */
.md-workspace {
  border: 2px solid rgba(241,240,234,.15);
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 560px;
}

.tool-section:not(.tool-section--dark) .md-workspace { border-color: var(--ink); }

.md-workspace[data-tab="write"]   { grid-template-columns: 1fr; }
.md-workspace[data-tab="preview"] { grid-template-columns: 1fr; }
.md-workspace[data-tab="write"]   .md-pane--preview { display: none; }
.md-workspace[data-tab="preview"] .md-pane--write   { display: none; }

.md-pane {
  display: flex;
  flex-direction: column;
  min-height: 560px;
}

.md-pane--write {
  border-right: 1px solid rgba(241,240,234,.12);
  position: relative; /* needed for drop overlay */
}

.tool-section:not(.tool-section--dark) .md-pane--write { border-right-color: var(--ink); }

/* Drop zone overlay */
.md-drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(17, 17, 17, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s linear;
  border: 3px dashed var(--red);
}

.md-drop-overlay.active {
  opacity: 1;
  pointer-events: none; /* let drop event pass through to the pane */
}

.tool-section:not(.tool-section--dark) .md-drop-overlay {
  background: rgba(241, 240, 234, 0.92);
  border-color: var(--red);
}

.md-drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

.md-drop-icon {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 3rem;
  font-weight: 700;
  color: var(--red);
  animation: dropBounce 0.8s ease-in-out infinite;
}

@keyframes dropBounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

.md-drop-label {
  font-family: 'Space Mono', monospace;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .2em;
  color: var(--paper);
  text-transform: uppercase;
}

.tool-section:not(.tool-section--dark) .md-drop-label { color: var(--ink); }

.md-pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(241,240,234,.1);
  font-family: 'Space Mono', monospace;
  font-size: .58rem;
  letter-spacing: .2em;
  color: rgba(241,240,234,.35);
  text-transform: uppercase;
  background: rgba(255,255,255,.02);
}

.tool-section:not(.tool-section--dark) .md-pane-header {
  border-bottom-color: var(--ink-faint);
  color: var(--ink-light);
  background: rgba(17,17,17,.02);
}

.md-stats { letter-spacing: .06em; }

.md-textarea {
  flex: 1;
  width: 100%;
  font-family: 'Space Mono', monospace;
  font-size: .82rem;
  line-height: 1.75;
  background: transparent;
  color: rgba(241,240,234,.85);
  border: none;
  padding: 20px;
  resize: none;
  outline: none;
  min-height: 520px;
}

.tool-section:not(.tool-section--dark) .md-textarea { color: var(--ink); }

.md-textarea--output {
  color: var(--ink-mid);
  background: rgba(17,17,17,.03);
}

.md-textarea:focus { box-shadow: none; }

/* Preview pane rendered output */
.md-preview {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1rem;
  line-height: 1.8;
  color: rgba(241,240,234,.85);
  max-width: 100%;
}

.tool-section:not(.tool-section--dark) .md-preview { color: var(--ink); }

/* Rendered MD styles */
.md-preview h1, .md-preview h2, .md-preview h3, .md-preview h4, .md-preview h5, .md-preview h6 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
  margin: 24px 0 10px;
}

.md-preview h1 { font-size: clamp(1.4rem,3vw,1.9rem); border-bottom: 2px solid var(--red); padding-bottom: 8px; }
.md-preview h2 { font-size: clamp(1.2rem,2.5vw,1.5rem); }
.md-preview h3 { font-size: 1.15rem; }
.md-preview h4 { font-size: 1rem; }
.md-preview p  { margin-bottom: 14px; }

.md-preview ul, .md-preview ol { margin: 0 0 14px 20px; }
.md-preview li { margin-bottom: 5px; }

.md-preview strong { font-weight: 700; font-family: 'Space Grotesk', sans-serif; }
.md-preview em { font-style: italic; }

.md-preview code {
  font-family: 'Space Mono', monospace;
  font-size: .8rem;
  background: rgba(241,240,234,.08);
  padding: 2px 6px;
  border: 1px solid rgba(241,240,234,.12);
}

.tool-section:not(.tool-section--dark) .md-preview code {
  background: rgba(17,17,17,.07);
  border-color: var(--ink-faint);
}

.md-preview pre {
  background: rgba(0,0,0,.4);
  border: 1px solid rgba(241,240,234,.1);
  padding: 16px 18px;
  margin-bottom: 16px;
  overflow-x: auto;
  border-radius: 0;
}

.tool-section:not(.tool-section--dark) .md-preview pre {
  background: rgba(17,17,17,.06);
  border-color: var(--ink-faint);
}

.md-preview pre code { background: none; border: none; padding: 0; font-size: .78rem; }

.md-preview blockquote {
  border-left: 4px solid var(--red);
  padding: 8px 16px;
  margin: 0 0 14px;
  color: rgba(241,240,234,.55);
  font-style: italic;
}

.tool-section:not(.tool-section--dark) .md-preview blockquote { color: var(--ink-mid); }

.md-preview a { color: var(--red); text-decoration: underline; }
.md-preview a:hover { opacity: .75; }

.md-preview hr { border: none; border-top: 2px solid rgba(241,240,234,.1); margin: 24px 0; }
.tool-section:not(.tool-section--dark) .md-preview hr { border-top-color: var(--ink-faint); }

.md-preview table { border-collapse: collapse; width: 100%; margin-bottom: 14px; }
.md-preview th, .md-preview td { border: 1px solid rgba(241,240,234,.12); padding: 8px 12px; text-align: left; font-family: 'Space Mono', monospace; font-size: .78rem; }
.md-preview th { background: rgba(241,240,234,.06); font-weight: 700; }
.tool-section:not(.tool-section--dark) .md-preview th,
.tool-section:not(.tool-section--dark) .md-preview td { border-color: var(--ink-faint); }
.tool-section:not(.tool-section--dark) .md-preview th { background: rgba(17,17,17,.04); }

.md-preview img { max-width: 100%; height: auto; }

/* hljs override in dark pane */
.tool-section--dark .hljs {
  background: transparent;
  color: rgba(241,240,234,.8);
  font-size: .78rem;
}

/* Footer bar */
.md-footer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border: 2px solid rgba(241,240,234,.1);
  border-top: none;
  flex-wrap: wrap;
}

.tool-section:not(.tool-section--dark) .md-footer-bar { border-color: var(--ink); background: rgba(17,17,17,.02); }

.md-footer-note {
  font-family: 'Space Mono', monospace;
  font-size: .58rem;
  letter-spacing: .08em;
  color: rgba(241,240,234,.3);
}

.tool-section:not(.tool-section--dark) .md-footer-note { color: var(--ink-light); }

.md-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: 'Space Mono', monospace;
  font-size: .6rem;
  letter-spacing: .1em;
  color: rgba(241,240,234,.45);
}

.tool-section:not(.tool-section--dark) .md-toggle-wrap { color: var(--ink-light); }

.md-toggle-input { cursor: pointer; accent-color: var(--red); }

/* ===========================
   TEXT → MARKDOWN TOOL
   =========================== */
.txt-md-tool { max-width: 1200px; }

.txt-md-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 16px 20px;
  border: 2px solid var(--ink);
  background: rgba(17,17,17,.03);
}

.txt-md-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Space Mono', monospace;
  font-size: .65rem;
  letter-spacing: .1em;
  color: var(--ink-mid);
  cursor: pointer;
  padding: 4px 10px;
  border: 1px solid var(--ink-faint);
  transition: background .08s, color .08s, border-color .08s;
}

.txt-md-opt:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.txt-md-checkbox { cursor: pointer; accent-color: var(--red); }

.txt-md-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 2px solid var(--ink);
  min-height: 520px;
}

.txt-md-pane {
  display: flex;
  flex-direction: column;
  border-right: 2px solid var(--ink);
}

.txt-md-pane--output { border-right: none; }

.txt-md-pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 2px solid var(--ink);
  font-family: 'Space Mono', monospace;
  font-size: .6rem;
  letter-spacing: .2em;
  color: var(--ink-light);
  text-transform: uppercase;
  background: rgba(17,17,17,.03);
  flex-wrap: wrap;
  gap: 8px;
}

.txt-md-header-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ===========================
   VISUALLY HIDDEN (for file inputs)
   =========================== */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ===========================
   FOOTER (tools page)
   =========================== */
#footer .footer-main { padding-top: 40px; }

/* ===========================
   RESPONSIVE
/* ===========================
   IMAGE TOOLS (Shared)
   =========================== */
.img-tool {
  display: flex;
  flex-direction: column;
}

/* Drop Zone */
.img-drop-zone {
  border-bottom: 2px solid var(--ink);
  background: rgba(0,0,0,0.02);
  transition: background 0.2s;
  position: relative;
}
.tool-section--dark .img-drop-zone {
  border-color: rgba(241,240,234,.12);
  background: rgba(255,255,255,0.02);
}
.img-drop-zone.dragover {
  background: var(--ink);
  color: var(--paper);
}
.tool-section--dark .img-drop-zone.dragover {
  background: var(--paper);
  color: var(--ink);
}

.img-drop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  cursor: pointer;
  text-align: center;
}
.img-drop-icon {
  font-size: 2rem;
  margin-bottom: 16px;
  opacity: 0.5;
}
.img-drop-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: .05em;
  margin-bottom: 8px;
}
.img-drop-sub {
  font-family: 'Space Mono', monospace;
  font-size: .8rem;
  opacity: 0.7;
}

/* Loaded View */
.img-loaded-view {
  display: flex;
  align-items: center;
  padding: 24px;
  gap: 24px;
}
.img-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border: 2px solid currentColor;
  background: repeating-conic-gradient(#ccc 0% 25%, transparent 0% 50%) 50% / 20px 20px;
}
.tool-section--dark .img-thumb {
  background: repeating-conic-gradient(#333 0% 25%, transparent 0% 50%) 50% / 20px 20px;
}
.img-file-info {
  flex: 1;
  min-width: 0;
}
.img-info-name {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.img-info-sub {
  font-family: 'Space Mono', monospace;
  font-size: .85rem;
  opacity: 0.7;
}
.img-change-btn {
  background: none;
  border: 1px solid currentColor;
  color: inherit;
  padding: 8px 16px;
  font-family: 'Space Mono', monospace;
  font-size: .85rem;
  cursor: pointer;
  text-transform: uppercase;
}
.img-change-btn:hover {
  background: currentColor;
  color: var(--paper);
}
.tool-section--dark .img-change-btn:hover {
  color: var(--ink);
}

/* Options Area */
.img-opts-row {
  display: grid;
  grid-template-columns: auto 1fr;
  border-bottom: 2px solid var(--ink);
}
.tool-section--dark .img-opts-row {
  border-color: rgba(241,240,234,.12);
}
.img-fieldset {
  border: none;
  border-right: 2px solid var(--ink);
  padding: 24px;
  margin: 0;
}
.tool-section--dark .img-fieldset {
  border-color: rgba(241,240,234,.12);
}
.img-fmt-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.img-fmt-btn-wrap {
  cursor: pointer;
}
.img-fmt-btn-wrap input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.img-fmt-btn {
  display: inline-block;
  padding: 8px 16px;
  border: 2px solid var(--ink);
  font-family: 'Space Mono', monospace;
  font-size: .9rem;
  font-weight: 700;
  transition: all 0.2s;
}
.tool-section--dark .img-fmt-btn {
  border-color: var(--paper);
}
.img-fmt-btn-wrap input:checked + .img-fmt-btn {
  background: var(--ink);
  color: var(--paper);
}
.tool-section--dark .img-fmt-btn-wrap input:checked + .img-fmt-btn {
  background: var(--paper);
  color: var(--ink);
}

.img-quality-wrap, .img-resize-opts, .img-compress-opts {
  padding: 24px;
}
.img-slider {
  width: 100%;
  margin: 16px 0;
  appearance: none;
  height: 4px;
  background: currentColor;
  outline: none;
}
.img-slider::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--paper);
  border: 2px solid var(--ink);
  cursor: pointer;
  border-radius: 50%;
}
.tool-section--dark .img-slider::-webkit-slider-thumb {
  background: var(--ink);
  border-color: var(--paper);
}

.img-quality-presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.img-preset-btn {
  background: none;
  border: 1px solid currentColor;
  color: inherit;
  padding: 4px 12px;
  font-family: 'Space Mono', monospace;
  font-size: .75rem;
  cursor: pointer;
  opacity: 0.7;
}
.img-preset-btn:hover {
  opacity: 1;
  background: currentColor;
  color: var(--paper);
}
.tool-section--dark .img-preset-btn:hover {
  color: var(--ink);
}

.img-quality-note {
  font-size: 0.75rem;
  opacity: 0.6;
  font-weight: normal;
  margin-left: 8px;
}

/* Actions & Status */
.img-actions {
  padding: 24px;
  border-bottom: 2px solid var(--ink);
  display: flex;
}
.tool-section--dark .img-actions {
  border-color: rgba(241,240,234,.12);
}
.img-process-btn {
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--ink);
  padding: 16px 32px;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  width: 100%;
  text-align: center;
  transition: all 0.2s;
}
.tool-section--dark .img-process-btn {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
}
.img-process-btn:hover {
  background: transparent;
  color: var(--ink);
}
.tool-section--dark .img-process-btn:hover {
  background: transparent;
  color: var(--paper);
}

.img-status {
  padding: 16px 24px;
  font-family: 'Space Mono', monospace;
  font-size: .85rem;
  min-height: 52px;
}
.img-status.error {
  color: #ff3333;
}

/* Size Bar */
.img-size-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 2px solid var(--ink);
  background: rgba(0,0,0,0.03);
}
.tool-section--dark .img-size-bar {
  border-color: rgba(241,240,234,.12);
  background: rgba(255,255,255,0.03);
}
.img-size-cell {
  display: flex;
  flex-direction: column;
}
.img-size-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  opacity: 0.6;
  margin-bottom: 4px;
}
.img-size-val {
  font-family: 'Space Mono', monospace;
  font-size: 1.1rem;
  font-weight: 700;
}
.img-size-val--new {
  color: #22aa22;
}
.tool-section--dark .img-size-val--new {
  color: #44ee44;
}
.img-savings {
  margin-left: auto;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 4px 8px;
  background: currentColor;
  color: var(--paper);
}
.tool-section--dark .img-savings {
  color: var(--ink);
}

/* Resizer Tabs & Inputs */
.img-mode-tabs {
  display: flex;
  border-bottom: 2px solid var(--ink);
}
.tool-section--dark .img-mode-tabs {
  border-color: rgba(241,240,234,.12);
}
.img-mode-tab {
  flex: 1;
  background: none;
  border: none;
  border-right: 2px solid var(--ink);
  padding: 16px;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.5;
}
.img-mode-tab:last-child {
  border-right: none;
}
.tool-section--dark .img-mode-tab {
  border-color: rgba(241,240,234,.12);
  color: var(--paper);
}
.img-mode-tab--active {
  opacity: 1;
  background: rgba(0,0,0,0.05);
}
.tool-section--dark .img-mode-tab--active {
  background: rgba(255,255,255,0.05);
}

.img-resize-panel, .img-crop-panel {
  padding: 24px;
  border-bottom: 2px solid var(--ink);
}
.tool-section--dark .img-resize-panel, .tool-section--dark .img-crop-panel {
  border-color: rgba(241,240,234,.12);
}
.img-resize-opts {
  padding: 0; /* remove padding from container */
}

.img-dim-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.img-dim-field {
  flex: 1;
}
.img-dim-input {
  width: 100%;
  background: transparent;
  border: 2px solid var(--ink);
  color: inherit;
  padding: 12px;
  font-family: 'Space Mono', monospace;
  font-size: 1rem;
}
.tool-section--dark .img-dim-input {
  border-color: rgba(241,240,234,.3);
}
.img-dim-input:focus {
  outline: none;
  border-color: currentColor;
}
.img-lock-btn {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.5rem;
  cursor: pointer;
  margin-top: 24px;
  opacity: 0.4;
}
.img-lock-btn[aria-pressed="true"] {
  opacity: 1;
}
.img-crop-hint {
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  opacity: 0.7;
  margin: 0;
}


/* ===========================
   MEDIA QUERIES
   =========================== */
  .yt-options { grid-template-columns: 1fr; }
  .yt-fieldset { border-right: none; border-bottom: 2px solid var(--ink); }
  .yt-fieldset:last-child { border-bottom: none; }
  .md-workspace { grid-template-columns: 1fr; }
  .md-workspace[data-tab="split"] .md-pane--write { border-right: none; border-bottom: 2px solid rgba(241,240,234,.12); }
  .txt-md-workspace { grid-template-columns: 1fr; }
  .txt-md-pane { border-right: none; border-bottom: 2px solid var(--ink); }
  .txt-md-pane--output { border-bottom: none; }
}

@media (max-width: 600px) {
  .tools-jumps { flex-direction: column; }
  .md-toolbar { flex-direction: column; align-items: flex-start; }
  .yt-url-input-wrap { flex-direction: column; }
  .yt-paste-btn { width: 100%; padding: 12px; }
  .yt-download-btn { width: 100%; justify-content: center; }
  .yt-result-inner { flex-direction: column; align-items: flex-start; }
  .yt-result-link { width: 100%; text-align: center; }
  .tool-section-head { flex-direction: column; }
  .txt-md-header-actions { flex-direction: column; }
}
