*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  display: flex;
  justify-content: center;
  align-items: stretch;
}

:root {
  --bg: radial-gradient(circle at top, #0f172a, #020617);
  --bg-panel: rgba(15, 23, 42, 0.85);
  --bg-panel-strong: rgba(15, 23, 42, 0.95);
  --border-soft: rgba(30, 64, 175, 0.6);
  --border-strong: rgba(55, 65, 81, 0.9);
  --border-muted: rgba(148, 163, 184, 0.6);
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --accent-secondary: #22c55e;
}

body[data-theme="dark"] {
  background: var(--bg);
  color: var(--text-main);
}

body[data-theme="light"] {
  background: radial-gradient(circle at top, #f9fafb, #e5e7eb);
  color: #020617;
  --bg-panel: #ffffff;
  --bg-panel-strong: #f9fafb;
  --border-soft: rgba(148, 163, 184, 0.6);
  --border-strong: rgba(148, 163, 184, 0.9);
  --border-muted: rgba(209, 213, 219, 0.9);
  --text-main: #020617;
  --text-muted: #6b7280;
}

.page {
  width: 100%;
  max-width: 960px;
  padding: 24px 16px 48px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 0.05em;
}

.logo span {
  color: var(--accent);
}

.logo,
.logo:link,
.logo:visited,
.logo:active,
.logo:hover {
  color: var(--text-main);
  text-decoration: none;
}

.tagline {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

main {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.uploader {
  margin-bottom: 8px;
}

.link-upload {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--bg-panel-strong);
  border: 1px solid var(--border-strong);
}

.link-upload-title {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 500;
}

.link-upload-subtitle {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.link-upload-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.link-upload-input {
  flex: 1;
  min-width: 0;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  padding: 7px 12px;
  background: var(--bg-panel-strong);
  color: var(--text-main);
  font-size: 13px;
}

.link-upload-input::placeholder {
  color: var(--text-muted);
}

.link-upload-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.7);
}

.link-upload-button {
  white-space: nowrap;
}

.dropzone {
  border-radius: 18px;
  border: 1px dashed var(--border-muted);
  padding: 32px 20px;
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.15), transparent),
    radial-gradient(circle at top right, rgba(94, 234, 212, 0.12), transparent),
    var(--bg-panel);
  backdrop-filter: blur(12px);
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease,
    box-shadow 0.2s ease;
  cursor: pointer;
}

.dropzone-inner {
  max-width: 520px;
  margin: 0 auto;
  text-align: center;
}

.dropzone-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
}

.dropzone-subtitle {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--text-muted);
}

.dropzone-hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.dropzone-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5),
    0 25px 50px -12px rgba(15, 118, 110, 0.7);
  transform: translateY(-2px);
}

.button-primary {
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent-secondary));
  color: #f9fafb;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 12px 25px rgba(34, 197, 94, 0.35);
}

.button-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(34, 197, 94, 0.45);
}

.button-primary:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 6px 15px rgba(34, 197, 94, 0.4);
}

.button-primary:disabled {
  opacity: 0.78;
  cursor: not-allowed;
  box-shadow: 0 6px 15px rgba(34, 197, 94, 0.25);
}

.button-secondary {
  border-radius: 999px;
  border: 1px solid var(--border-muted);
  padding: 6px 14px;
  background: var(--bg-panel-strong);
  color: var(--text-main);
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.button-secondary:hover {
  background: var(--bg-panel);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.button-ghost {
  border-radius: 999px;
  border: none;
  padding: 4px 10px;
  background: transparent;
  color: #9ca3af;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.button-ghost:hover {
  color: #f97316;
  background-color: rgba(15, 23, 42, 0.1);
}

.queue,
.results {
  background: var(--bg-panel);
  border-radius: 16px;
  padding: 16px 16px 18px;
  border: 1px solid var(--border-soft);
}

.queue h2,
.results h2 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

.queue-list,
.results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--bg-panel-strong);
  border: 1px solid var(--border-strong);
}

.queue-thumb {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-panel);
}

.queue-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.queue-info {
  flex: 1;
  min-width: 0;
}

.queue-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.queue-name {
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.queue-size {
  font-size: 11px;
  color: var(--text-muted);
}

.queue-remove {
  flex-shrink: 0;
}

.queue-empty {
  font-size: 13px;
  color: var(--text-muted);
}

.results {
  display: none;
}

.crop-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.crop-overlay-visible {
  display: flex;
}

.crop-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(6px);
}

.crop-dialog {
  position: relative;
  z-index: 41;
  width: min(640px, 100% - 32px);
  max-height: 80vh;
  border-radius: 16px;
  background: var(--bg-panel-strong);
  border: 1px solid var(--border-soft);
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.crop-header {
  font-size: 15px;
  font-weight: 600;
}

.crop-body {
  flex: 1;
  min-height: 220px;
  max-height: 420px;
}

.crop-stage {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #020617;
}

.crop-image {
  max-width: 100%;
  max-height: 100%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.crop-box {
  position: absolute;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.crop-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.result-item {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--bg-panel-strong);
  border: 1px solid var(--border-strong);
}

.result-thumb {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-panel);
}

.result-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-url {
  width: 100%;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  padding: 6px 10px;
  background: var(--bg-panel-strong);
  color: var(--text-main);
  font-size: 12px;
}

.result-url:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.8);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg-panel-strong);
  border: 1px solid var(--border-muted);
  color: var(--text-main);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-visible {
  opacity: 1;
  transform: translate(-50%, -4px);
}

@media (max-width: 640px) {
  .page {
    padding-inline: 12px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .dropzone {
    padding: 24px 16px;
  }

  .dropzone-title {
    font-size: 18px;
  }

  .queue-item,
  .result-item {
    padding: 8px;
  }

  .result-thumb {
    width: 52px;
    height: 52px;
  }
}

