:root {
  --bg: #0c0e12;
  --surface: #141820;
  --border: #252a36;
  --text: #e8eaef;
  --muted: #8b93a7;
  --accent: #6ee7b7;
  --accent-dim: #34d399;
  --danger: #f87171;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, #1a2435 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #13221c 0%, transparent 50%), var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  max-width: 820px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.brand {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.brand.center {
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.account {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(145deg, #1f2a38, #12161c);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 1.1rem;
}

h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.script {
  width: 100%;
  resize: vertical;
  min-height: 280px;
  padding: 1rem 1.1rem;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.script::placeholder {
  color: #5c6478;
}

.script:focus {
  border-color: #3d4f66;
  box-shadow: 0 0 0 3px rgba(110, 231, 183, 0.12);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}

.meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 2.5rem;
  justify-content: center;
}

.mono {
  font-family: var(--mono);
  font-size: 0.82rem;
}

.status {
  font-size: 0.88rem;
  color: var(--muted);
}

.status.busy {
  color: var(--accent-dim);
}

.status.error {
  color: var(--danger);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.btn {
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.65rem 1.35rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #1a1f28;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}

.btn:hover:not(:disabled) {
  background: #222833;
  border-color: #363d4d;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(165deg, #3d9f7a, #2d7a5c);
  border-color: #2f8f6a;
  color: #04120c;
}

.btn.primary:hover:not(:disabled) {
  background: linear-gradient(165deg, #47b88e, #338f6d);
  border-color: #3aa67e;
}

.hint {
  margin: 1.75rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.6;
}

.hint code {
  font-size: 0.8em;
  padding: 0.12em 0.4em;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.btn.small {
  font-size: 0.82rem;
  padding: 0.4rem 0.85rem;
}

.btn.full {
  width: 100%;
  margin-top: 0.5rem;
}

.btn.danger {
  color: var(--danger);
  border-color: #4a2a30;
}

.btn.danger:hover:not(:disabled) {
  background: #2a1c20;
  border-color: #6a3a42;
}

/* ---- Auth page ---- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  background: #11151c;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.25rem;
  margin-bottom: 1.5rem;
}

.tab {
  flex: 1;
  padding: 0.55rem;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

.tab.active {
  background: #1f2630;
  color: var(--text);
}

.auth-form {
  display: flex;
  flex-direction: column;
}

.input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  margin-bottom: 1rem;
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  border-color: #3d4f66;
  box-shadow: 0 0 0 3px rgba(110, 231, 183, 0.12);
}

/* ---- Library ---- */
.library {
  margin-top: 2.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.library-head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.clip-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.clip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.clip-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.clip-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clip-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.clip-ctrls {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

@media (max-width: 520px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .actions {
    width: 100%;
  }

  .actions .btn {
    flex: 1;
  }

  .header {
    flex-direction: column;
  }

  .clip {
    flex-direction: column;
    align-items: stretch;
  }
}
