:root {
  --bg: #fff;
  --fg: #111;
  --muted: #666;
  --card: #f7f7f8;
  --border: #e5e7eb;
  --accent: #2563eb;

  --back-btn-bg: rgba(220, 220, 220, 0.3);
  --back-btn-color: #111;

  --radius: 12px;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0c0f;
    --fg: #e5e7eb;
    --muted: #a1a1aa;
    --card: #111317;
    --border: #25262b;
    --accent: #60a5fa;

    --back-btn-bg: rgba(120, 120, 120, 0.3);
    --back-btn-color: #e5e5e5;

    --shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Arial;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
}

.header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand h1 {
  font-size: 18px;
  margin: 0;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
  justify-content: space-between;
  transition: all 0.3s ease;
  width: 100%;
}

.controls {
  display: flex;
  gap: 10px;
  flex: 1;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}

input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--fg);
  outline: none;
  max-width: 360px;
  line-height: normal;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

button,
.btn {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

button:hover,
.btn:hover {
  background-color: var(--accent);
  color: #fff;
  transform: scale(1.03);
}

button:active,
.btn:active {
  transform: scale(0.97);
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(10px) scale(0.95);
  background: rgba(255, 255, 255, 0.9);
  color: #111;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  opacity: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90vw;
  text-align: center;
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease,
    color 0.2s ease;
  z-index: 2000;
}

@media (prefers-color-scheme: dark) {
  .toast {
    background: rgba(50, 50, 50, 0.9);
    color: #e5e7eb;
  }
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 12px;
  color: var(--muted);
  min-width: 50px;
  text-align: right;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
  margin-top: 18px;
}

.card {
  grid-column: span 12;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

@media (min-width: 720px) {
  .card {
    grid-column: span 6;
  }
}

.card .header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.card .header-row h3 {
  margin: 0;
  font-size: 16px;
}

.card .meta {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: space-between;
}

.card .meta button {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
}

.card pre {
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 10px;
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 13px;
}

.progress-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}

.progress {
  height: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  flex: 1;
  transition: all 0.2s ease;
}

.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s ease;
}

html,
body {
  height: 100%;
  margin: 0;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal.show {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: var(--card);
  color: var(--fg);
  border-radius: var(--radius);
  max-width: 800px;
  width: 90%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  overflow: hidden;
  transform: scale(0.95);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.modal.show .modal-content {
  transform: scale(1);
}

.modal-content.small {
  max-width: 320px;
  width: 90%;
  max-height: 50%;
}

.modal-header {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  z-index: 10;
}

#modalBody {
  flex: 1 1 auto;
  padding: 12px 16px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--card);
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 13px;
}

.modal-close {
  cursor: pointer;
  font-size: 18px;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--card);
  transition: color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.modal-close:hover {
  color: var(--accent);
  transform: scale(1.2);
  background: rgba(0, 0, 0, 0.05);
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: nowrap;
  padding: 12px 16px;
}

@media (max-width: 600px) {
  .modal-content:not(.small) {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .modal-content.small {
    width: 90%;
    max-height: 40%;
    border-radius: var(--radius);
  }

  .modal-content.small #confirmBody {
    padding: 12px;
    font-size: 13px;
  }
}

#backToTop {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--back-btn-bg);
  color: var(--back-btn-color);
  border: none;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;
  text-align: center;
  line-height: 1;
  transition: opacity 0.2s ease, transform 0.2s ease;
  opacity: 0;
  pointer-events: none;
}

#backToTop.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#backToTop:hover {
  transform: scale(1.1);
  background-color: var(--accent);
  color: #fff;
}
