/* MesmerTools HuggingFace Spaces — shared dark theme.
   Tokens mirror DESIGN.md so the spaces feel like the main site. */

:root {
  --bg: #0d0d0d;
  --bg-elevated: #161616;
  --bg-card: #1a1a1a;
  --bg-card-hover: #222222;
  --border: #2a2a2a;
  --border-hover: #3a3a3a;
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.15);
  --amber-glow: rgba(245, 158, 11, 0.35);
  --sienna: #c2410c;
  --text-primary: #eeeeee;
  --text-secondary: #999999;
  --text-muted: #666666;
  --grad: linear-gradient(135deg, var(--amber), var(--sienna));
  --radius: 10px;
  --maxw: 880px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Header --------------------------------------------------------- */
.ms-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding: 0 20px;
  background: rgba(13, 13, 13, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.ms-brand { display: flex; align-items: center; gap: 9px; color: var(--text-primary); }
.ms-brand:hover { text-decoration: none; }
.ms-brand-mark {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--grad);
  color: var(--bg);
  font-weight: 800;
  font-size: 15px;
}
.ms-brand-name { font-weight: 700; letter-spacing: -0.3px; }
.ms-header-link { color: var(--text-secondary); font-size: 13px; font-weight: 500; }
.ms-header-link:hover { color: var(--amber); text-decoration: none; }

/* --- Layout --------------------------------------------------------- */
.ms-main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 40px 20px 8px;
}

.ms-hero { text-align: center; margin-bottom: 28px; }
.ms-hero-emoji { font-size: 40px; line-height: 1; margin-bottom: 12px; }
.ms-title {
  margin: 0 0 10px;
  font-size: clamp(26px, 5vw, 38px);
  font-weight: 800;
  letter-spacing: -0.8px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.ms-subtitle { margin: 0 auto; max-width: 620px; color: var(--text-secondary); font-size: 16px; }
.ms-intro { margin: 12px auto 0; max-width: 620px; color: var(--text-muted); font-size: 14px; }
.ms-limit-note {
  display: inline-block;
  margin-top: 16px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 12px;
}

/* --- Card ----------------------------------------------------------- */
.ms-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
}

/* --- Forms (generic, reusable by every space) ----------------------- */
.ms-form { display: flex; flex-direction: column; gap: 16px; }
.ms-field { display: flex; flex-direction: column; gap: 6px; }
.ms-field label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.ms-field .ms-hint { font-size: 12px; color: var(--text-muted); }
.ms-row { display: flex; gap: 12px; flex-wrap: wrap; }
.ms-row > .ms-field { flex: 1 1 160px; }

.ms-input, .ms-textarea, .ms-select {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ms-textarea { resize: vertical; min-height: 110px; }
.ms-input:focus, .ms-textarea:focus, .ms-select:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-dim);
}
.ms-input::placeholder, .ms-textarea::placeholder { color: var(--text-muted); }
.ms-select { appearance: none; cursor: pointer; }

/* --- Buttons -------------------------------------------------------- */
.ms-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  background: var(--grad);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s, filter 0.15s;
}
.ms-btn:hover { filter: brightness(1.08); }
.ms-btn:active { transform: translateY(1px); }
.ms-btn:disabled { opacity: 0.55; cursor: not-allowed; filter: none; }
.ms-btn-ghost {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.ms-btn-ghost:hover { border-color: var(--border-hover); filter: none; }

.ms-char-count { font-size: 12px; color: var(--text-muted); text-align: right; }

/* --- Status banners ------------------------------------------------- */
.ms-status:empty { display: none; }
.ms-status { margin-top: 16px; }
.ms-banner {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 14px;
  border: 1px solid var(--border);
}
.ms-banner-error { background: rgba(220, 38, 38, 0.1); border-color: rgba(220, 38, 38, 0.4); color: #fca5a5; }
.ms-banner-limit { background: var(--amber-dim); border-color: var(--amber-glow); color: #fcd9a0; }
.ms-banner-limit .ms-banner-cta { display: inline-block; margin-top: 4px; font-weight: 700; }
.ms-banner-loading { display: flex; align-items: center; gap: 10px; background: var(--bg-elevated); color: var(--text-secondary); }
.ms-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border-hover);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: ms-spin 0.7s linear infinite;
}
@keyframes ms-spin { to { transform: rotate(360deg); } }

/* --- Output --------------------------------------------------------- */
.ms-output:empty { display: none; }
.ms-output { margin-top: 18px; }
.ms-output img, .ms-output video { max-width: 100%; border-radius: 10px; display: block; }
.ms-result-frame {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-elevated);
}
.ms-result-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.ms-meta { margin-top: 10px; font-size: 12px; color: var(--text-muted); }
.ms-audio { width: 100%; margin-top: 6px; }

/* --- Footer cross-sell ---------------------------------------------- */
.ms-footer {
  max-width: var(--maxw);
  margin: 48px auto 0;
  padding: 28px 20px 56px;
  border-top: 1px solid var(--border);
}
.ms-footer-title {
  margin: 0 0 16px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}
.ms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.ms-tool-card {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.2s, background 0.2s;
}
.ms-tool-card:hover {
  transform: translateY(-3px);
  background: var(--bg-card-hover);
  border-color: var(--amber-glow);
  text-decoration: none;
}
.ms-tool-emoji { font-size: 20px; line-height: 1.3; }
.ms-tool-text { display: flex; flex-direction: column; gap: 2px; }
.ms-tool-name { color: var(--text-primary); font-weight: 600; font-size: 14px; }
.ms-tool-desc { color: var(--text-secondary); font-size: 12.5px; }
.ms-powered { margin: 22px 0 0; color: var(--text-muted); font-size: 12.5px; }

/* --- Responsive ----------------------------------------------------- */
@media (max-width: 560px) {
  .ms-main { padding-top: 28px; }
  .ms-card { padding: 18px; }
  .ms-grid { grid-template-columns: 1fr; }
}
