/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d1016;
  --bg-soft: #131926;
  --panel: #171f2d;
  --panel-2: #1c2738;
  --border: #2b3a52;
  --text: #e8edf8;
  --text-muted: #98a7c1;
  --accent: #3f8cff;
  --accent-strong: #2d76e6;
  --danger: #ff5f7a;
  --danger-soft: #3b1d2a;
  --success: #36d07f;
  --success-soft: #153328;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 12px 30px rgba(2, 8, 20, 0.45);
  --font: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  min-height: 100vh;
  background: radial-gradient(circle at 20% 0%, #1a2335 0, var(--bg) 50%);
  color: var(--text);
  padding: 1rem;
}

.app-shell {
  max-width: 1100px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent 25%), var(--bg-soft);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .95rem 1.15rem;
  border-bottom: 1px solid var(--border);
  background: #121827;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: .65rem;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(63, 140, 255, 0.2);
}

.app-topbar h1 {
  font-size: 1.02rem;
  letter-spacing: .04em;
  font-weight: 700;
}

.topbar-sub {
  font-size: .8rem;
  color: var(--text-muted);
}

.app-main {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem;
}

.app-side-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 1rem;
  height: fit-content;
}

.app-side-panel h2 {
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: .75rem;
}

.app-side-panel ul {
  list-style: none;
  display: grid;
  gap: .6rem;
}

.app-side-panel li {
  font-size: .85rem;
  color: var(--text-muted);
  border: 1px solid #334765;
  background: #1a2435;
  border-radius: var(--radius-sm);
  padding: .55rem .65rem;
}

.side-note {
  margin-top: .85rem;
  font-size: .78rem;
  line-height: 1.5;
  color: #b5c1d7;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 1.1rem;
}

.page-header h2 {
  font-size: 1.18rem;
  font-weight: 700;
}

.page-header p {
  margin-top: .35rem;
  font-size: .84rem;
  color: var(--text-muted);
}

.content-panel form { margin-top: .95rem; }

.drop-zone {
  border: 2px dashed #385072;
  border-radius: var(--radius);
  padding: 2rem .95rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
  background: #182437;
}

.drop-zone:hover,
.drop-zone.over {
  border-color: var(--accent);
  background: #1b2d44;
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.drop-zone__icon {
  font-size: 2rem;
  line-height: 1;
  pointer-events: none;
}

.drop-zone__label {
  display: block;
  margin-top: .65rem;
  font-size: .92rem;
  color: #d2dbee;
  pointer-events: none;
}

.drop-zone__sub {
  display: block;
  margin-top: .3rem;
  font-size: .8rem;
  color: var(--text-muted);
  pointer-events: none;
}

.drop-zone__file-name {
  display: block;
  margin-top: .55rem;
  font-size: .83rem;
  color: #8fc1ff;
  font-weight: 600;
  word-break: break-word;
  pointer-events: none;
}

.nsfw-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-top: 1rem;
}

.toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
}

.nsfw-row label {
  color: var(--text-muted);
  font-size: .88rem;
  cursor: pointer;
  user-select: none;
}

.toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 42px;
  height: 24px;
  border-radius: 12px;
  background: #324760;
  border: 1px solid #496386;
  position: relative;
  cursor: pointer;
  transition: background .2s;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #dbe4f6;
  transition: transform .2s;
}

.toggle:checked {
  background: #8d2f45;
  border-color: #ad3a56;
}

.toggle:checked::after { transform: translateX(18px); }

.nsfw-badge {
  font-size: .73rem;
  letter-spacing: .05em;
  color: #ff8fa3;
  border: 1px solid #a43a54;
  border-radius: 999px;
  padding: 2px 8px;
  opacity: 0;
  transition: opacity .2s;
}

.nsfw-badge.visible { opacity: 1; }

.btn-upload {
  width: 100%;
  margin-top: 1rem;
  padding: .78rem 1rem;
  border: 1px solid #5b93f0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #f4f8ff;
  font-family: var(--font);
  font-size: .97rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.btn-upload:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: #74a4f8;
}

.btn-upload:disabled {
  background: #29384e;
  border-color: #344862;
  color: #8da0bf;
  cursor: not-allowed;
}

.progress-wrap {
  margin-top: .95rem;
  display: none;
}

.progress-wrap.visible { display: block; }

.progress-bar-bg {
  height: 7px;
  border-radius: 4px;
  background: #24344a;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .1s linear;
}

.progress-text {
  margin-top: .35rem;
  font-size: .78rem;
  color: var(--text-muted);
  text-align: center;
}

.msg-error {
  margin-top: .95rem;
  border: 1px solid #8f3750;
  background: var(--danger-soft);
  color: #ff95a7;
  border-radius: var(--radius-sm);
  padding: .7rem .85rem;
  font-size: .88rem;
  display: none;
}

.msg-error.visible { display: block; }

.results-container { margin-top: 1.2rem; }

.results-wrap {
  display: grid;
  gap: .85rem;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  flex-wrap: wrap;
}

.results-title {
  font-size: .88rem;
  color: #86e9b2;
  font-weight: 700;
}

.btn-copy-all,
.btn-copy {
  border: 1px solid #4c6991;
  background: #203049;
  color: #b8d5ff;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}

.btn-copy-all {
  padding: .46rem .9rem;
}

.btn-copy {
  padding: .55rem .95rem;
}

.btn-copy-all:hover,
.btn-copy:hover {
  background: #254168;
  border-color: #6697d8;
  color: #d9e9ff;
}

.btn-copy-all.copied,
.btn-copy.copied {
  color: #8ae7b1;
  border-color: #3e8d66;
  background: #1c3b2d;
}

.result-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  overflow: hidden;
}

.result-thumb {
  width: 96px;
  min-width: 96px;
  height: 96px;
  object-fit: cover;
  background: #203047;
}

.result-item-body {
  flex: 1;
  min-width: 0;
  padding: .75rem .8rem .8rem 0;
}

.result-item-name {
  font-size: .77rem;
  color: var(--text-muted);
  margin-bottom: .45rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-row {
  display: flex;
  gap: .5rem;
  align-items: stretch;
}

.link-input {
  flex: 1;
  min-width: 0;
  border: 1px solid #40597a;
  background: #182639;
  color: #d9e6fb;
  border-radius: var(--radius-sm);
  padding: .54rem .7rem;
  font-size: .82rem;
  font-family: "Cascadia Mono", "Consolas", monospace;
}

.link-input:focus {
  outline: 2px solid #4b8ef7;
  outline-offset: 0;
}

.copy-hint {
  margin-top: .45rem;
  font-size: .75rem;
  color: var(--text-muted);
}

.result-item--error {
  border-color: #8f3750;
  background: #2a1b27;
}

.result-item-error-icon {
  width: 96px;
  min-width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ff87a0;
  background: #3a1f2c;
  font-size: 1.35rem;
}

.result-item-error-msg {
  margin-top: .2rem;
  font-size: .84rem;
  color: #ff9fb1;
}

.app-footer {
  border-top: 1px solid var(--border);
  padding: .8rem 1rem;
  font-size: .78rem;
  color: var(--text-muted);
  text-align: center;
  background: #121827;
}

@media (max-width: 900px) {
  .app-main {
    grid-template-columns: 1fr;
  }

  .app-side-panel {
    order: 2;
  }

  .content-panel {
    order: 1;
  }
}

@media (max-width: 560px) {
  body { padding: .4rem; }

  .app-topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .card { padding: .85rem; }

  .drop-zone { padding: 1.5rem .7rem; }

  .result-item {
    flex-direction: column;
  }

  .result-thumb,
  .result-item-error-icon {
    width: 100%;
    min-width: 100%;
    height: 170px;
  }

  .result-item-body {
    padding: .75rem;
  }

  .link-row {
    flex-direction: column;
  }

  .btn-copy,
  .btn-copy-all {
    width: 100%;
  }
}
