/* ════════════════════════════════════════════════════════════
   cobalt — self-hosted frontend (real cobalt.tools aesthetic)
   ════════════════════════════════════════════════════════════ */

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

:root {
  --bg:              #0f0f0f;
  --surface:         #1a1a1a;
  --surface-2:       #1e1e1e;
  --border:          #2a2a2a;
  --border-2:        #333;
  --text:            #d4d4d4;
  --text-2:          #a0a0a0;
  --text-3:          #666;
  --accent:          #c8a2ff;
  --accent-2:        #a8c5ff;
  --input-border:    #2a2a2a;
  --error:           #ff6b6b;
  --success:         #4ade80;
  --radius:          16px;
  --radius-sm:       10px;
  --radius-xs:       6px;
  --transition:      0.15s ease;
}

html  { height: 100%; -webkit-text-size-adjust: 100%; }
body  {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* ════════════════════════════════════════════════════════════
   Services strip (top)
   ════════════════════════════════════════════════════════════ */
#services-strip {
  width: 100%;
  padding: 16px 0 8px;
  display: flex;
  justify-content: center;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 10%, #000 90%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 10%, #000 90%, transparent 100%);
}
.services-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  opacity: 0.4;
}
.service-logo {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-xs);
  display: block;
  flex-shrink: 0;
}
.service-logo.yt { background: #ff0000; }
.service-logo.tw { background: #1d9bf0; }
.service-logo.tt { background: #ff0050; }
.service-logo.rd { background: #ff4500; }
.service-logo.ig { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); }
.service-logo.sc { background: #ff5500; }
.service-logo.bc { background: #fa5b5b; }

/* ════════════════════════════════════════════════════════════
   Main save area
   ════════════════════════════════════════════════════════════ */
#save-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 40px;
  gap: 16px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

/* ════════════════════════════════════════════════════════════
   Meowbalt (cat mascot)
   ════════════════════════════════════════════════════════════ */
#meowbalt {
  margin-bottom: 8px;
  transition: transform 0.3s ease;
}
#meowbalt:hover { transform: scale(1.05); }

/* ════════════════════════════════════════════════════════════
   Omnibox
   ════════════════════════════════════════════════════════════ */
#omnibox {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#input-container {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
#input-container:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
#input-container:has(.download-icon-btn:not([hidden])) {
  padding-right: 8px;
}

#input-icon {
  color: var(--text-3);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
#input-container:focus-within #input-icon {
  color: var(--accent);
}

#urlInput {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 2px 4px;
  caret-color: var(--accent);
  -webkit-tap-highlight-color: transparent;
}
#urlInput::placeholder { color: var(--text-3); }

/* Icon buttons inside omnibox */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-xs);
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover  { color: var(--text); background: rgba(255,255,255,0.05); }
.icon-btn:active { opacity: 0.7; }

.download-icon-btn {
  color: var(--text-2);
  transition: color var(--transition), background var(--transition), transform 0.1s ease;
}
.download-icon-btn:not([hidden]) { display: inline-flex; }
.download-icon-btn:hover {
  color: var(--accent);
  background: rgba(200, 162, 255, 0.08);
}
.download-icon-btn:active { transform: scale(0.92); }

#clearBtn { display: inline-flex; }
#clearBtn[hidden] { display: none; }

/* ════════════════════════════════════════════════════════════
   Action row (mode toggles + paste)
   ════════════════════════════════════════════════════════════ */
#action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
}

#mode-toggles {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.mode-btn:hover { border-color: var(--border-2); color: var(--text); }
.mode-btn:active { transform: scale(0.95); }
.mode-btn.active {
  background: rgba(200, 162, 255, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}
.mode-btn span { display: inline; }

.paste-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.paste-btn:hover { border-color: var(--border-2); color: var(--text); }
.paste-btn:active { transform: scale(0.95); }

/* ════════════════════════════════════════════════════════════
   Status
   ════════════════════════════════════════════════════════════ */
#status {
  width: 100%;
  min-height: 0;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  color: var(--text-2);
  transition: min-height var(--transition), padding var(--transition);
}
#status:not(:empty) {
  min-height: 32px;
  padding-top: 8px;
}
#status.error  { color: var(--error); }
#status.success { color: var(--success); }
#status a {
  color: var(--accent-2);
  text-decoration: underline;
  word-break: break-all;
}

/* ════════════════════════════════════════════════════════════
   Result card
   ════════════════════════════════════════════════════════════ */
#result-card {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: slideUp 0.2s ease;
}
#result-card[hidden] { display: none; }

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.result-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

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

#resultUrl {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  -webkit-user-select: all;
  user-select: all;
}
#resultUrl:focus { border-color: var(--border-2); }

.result-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius-xs);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  transition: all var(--transition);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.result-btn:hover  { background: var(--border); border-color: var(--text-3); }
.result-btn:active { transform: scale(0.95); }
.result-btn.copied {
  background: rgba(74, 222, 128, 0.1);
  border-color: var(--success);
  color: var(--success);
}

.result-hint {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.4;
}

/* ════════════════════════════════════════════════════════════
   Picker panel
   ════════════════════════════════════════════════════════════ */
#picker-panel {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: slideUp 0.2s ease;
}
#picker-panel[hidden] { display: none; }

.picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.picker-header span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: lowercase;
}

#picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.picker-item {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
  text-decoration: none;
  display: flex;
  flex-direction: column;
}
.picker-item:hover { border-color: var(--border-2); transform: translateY(-2px); }
.picker-item:active { transform: scale(0.98); }

.picker-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--border);
  display: block;
}
.picker-thumb-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
}
.picker-meta {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#picker-audio { padding-top: 8px; border-top: 1px solid var(--border); }
#picker-audio[hidden] { display: none; }

.audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  padding: 7px 12px;
  transition: all var(--transition);
}
.audio-btn:hover { color: var(--text); border-color: var(--border-2); background: var(--surface-2); }

/* ════════════════════════════════════════════════════════════
   Footer
   ════════════════════════════════════════════════════════════ */
#footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0.03em;
}

/* ════════════════════════════════════════════════════════════
   Floating settings button
   ════════════════════════════════════════════════════════════ */
.floating-settings {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.floating-settings:hover {
  color: var(--text);
  border-color: var(--border-2);
  background: var(--surface-2);
}
.floating-settings:active { transform: scale(0.92); }

/* ════════════════════════════════════════════════════════════
   Modal
   ════════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--surface);
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: slideUp 0.18s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1.5px solid var(--border);
}
.modal-header h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1.5px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* Setting groups */
.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.setting-group label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: default;
}
.setting-desc {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 400;
}

.setting-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.setting-row input,
select {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  transition: border-color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.setting-row input:focus,
select:focus { border-color: var(--border-2); }
.setting-row input::placeholder { color: var(--text-3); }

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
select option { background: var(--surface); color: var(--text); }

.toggle-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}
.toggle-row > div { display: flex; flex-direction: column; gap: 2px; }

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border-2);
  border-radius: 100px;
  transition: background var(--transition);
}
.toggle-track::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--text-2);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}
.toggle input:checked + .toggle-track { background: rgba(200, 162, 255, 0.25); }
.toggle input:checked + .toggle-track::before {
  transform: translateX(20px);
  background: var(--accent);
}

/* Save button */
.save-btn {
  background: var(--surface-2);
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius-xs);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 22px;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.save-btn:hover  { background: var(--border); border-color: var(--text-3); }
.save-btn:active { transform: scale(0.96); }

/* ════════════════════════════════════════════════════════════
   Animations
   ════════════════════════════════════════════════════════════ */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════════════════
   Responsive
   ════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  #save-area { padding: 16px 14px 32px; }
  .mode-btn span { display: none; }
  .mode-btn { padding: 6px 8px; }
  .paste-btn span { display: none; }
  .paste-btn { padding: 6px 8px; }
  .result-btn span { display: none; }
  .result-btn { padding: 8px; }
  .floating-settings { top: 12px; right: 12px; }
}

@media (max-width: 360px) {
  #picker-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}
