:root {
  --border-radius: 0.5rem;
  --border-color: #9ca3af;
  --source-color: hsl(204deg, 100%, 90%);
}

* {
  box-sizing: border-box;
  user-select: none;
}

input,
textarea {
  user-select: unset;
}

body {
  font-family: "Segoe UI Light", Calibri, helvetica, arial, sans-serif;
  font-size: 14px;
  margin: 1em;
  position: relative;
  background: linear-gradient(135deg, #eef0f3 0%, #f8f9fb 100%);
  min-height: 100vh;
  color: #111827;
  text-align: left;
}

h1, h2, h3 {
  text-align: left;
  margin-left: 0;
}

.panels {
  max-width: 1200px;
  margin: 0 auto 2rem;
}

.sources, .output {
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  padding: 1.5rem 1.25rem;
  margin-bottom: 2rem;
  border-radius: var(--border-radius);
  max-width: 1100px;
  min-width: 0;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
  width: 95vw;
}

@media (min-width: 1100px) {
  .panels {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
  }
  .sources, .output {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 0;
    flex: 1 1 0;
  }
}

@media (max-width: 900px) {
  .sources, .output {
    width: 98vw;
    max-width: 100vw;
    padding: 1rem 0.5rem;
  }
}

@media (max-width: 700px) {
  .sources, .output {
    padding: 0.5rem;
    width: 100vw;
    max-width: 100vw;
  }
  .install {
    right: 0.5rem;
    bottom: 0.5rem;
    padding: 0.5em 1em;
    font-size: 1em;
  }
  body {
    font-size: 16px;
    margin: 0.5em;
  }
}

@media (max-width: 480px) {
  .sources, .output {
    padding: 0.25rem;
    width: 100vw;
  }
  .source-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}

.sources ul {
  margin-bottom: 1rem;
  background: #f3f4f6;
  border-radius: var(--border-radius);
  padding: 0.75rem;
  list-style: none;
  margin-left: 0;
  padding-left: 0.75rem;
}

.sources ul li {
  padding: 1rem 0.5rem;
}

.source-item + .source-item {
  border-top: 1px solid rgba(17, 24, 39, 0.12);
  padding-top: 1.25rem;
}

.source-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 2fr);
  align-items: start;
  gap: 1rem;
}

.sources label, .drop-widget {
  font-weight: 500;
  margin-bottom: 0;
}

.source-row label {
  display: block;
  font-weight: 600;
}

.source-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.source-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.source-control > * {
  width: 100%;
  margin-right: 0;
}

.source-control input,
.source-control textarea {
  min-width: 0;
}

.drop-widget {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 6rem;
  padding: 1.25rem;
  text-align: center;
}

.sources input,
.sources textarea {
  width: 100%;
  padding: 0.5rem;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

.sources .local {
  display: none;
}

label[for="local"] {
  margin: 0;
}

.sources .text {
  width: 100%;
  min-height: 3.5rem;
  resize: vertical;
}

.sources .btn-paste,
.sources .btn-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  text-align: center;
}

input, textarea, button, .btn-paste {
  font-size: 1em;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  padding: 0.5em 0.75em;
  margin-right: 0.25em;
  background: #ffffff;
  transition: border 0.2s, box-shadow 0.2s, background 0.2s;
  text-align: left;
}

input[type="url"], input[type="text"], textarea {
  flex: 1 1 auto;
  min-width: 0;
}

input:focus, textarea:focus, button:focus, .btn-paste:focus {
  outline: 2px solid #6b7280;
  outline-offset: 2px;
  border-color: #6b7280;
  background: #f3f4f6;
}

button,
.btn-paste,
.btn-file,
.source-button,
.source-action {
  cursor: pointer;
  background: #e5e7eb;
  border: 1px solid #9ca3af;
  color: #111827;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(30,144,255,0.03);
  border-radius: var(--border-radius);
  transition: background 0.2s, border 0.2s, color 0.2s;
}

button:hover,
.btn-paste:hover,
.btn-file:hover,
.source-button:hover,
.source-action:hover,
button:focus,
.btn-paste:focus,
.btn-file:focus,
.source-button:focus,
.source-action:focus {
  background: #d1d5db;
  border-color: #6b7280;
  color: #111827;
  outline: none;
}

.copy {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 1em;
  font-weight: 600;
  background: #e5e7eb;
  border: 1px solid #9ca3af;
  color: #111827;
}

.copy:active {
  background: #b3e5fc;
}

.data-uri {
  display: inline-block;
  margin-bottom: 0.5rem;
  word-break: break-all;
  font-family: monospace;
  font-size: 0.95em;
  color: #ffffff;
  background: #111827;
  padding: 0.35rem 0.5rem;
  border-radius: calc(var(--border-radius) * 0.75);
  text-decoration: underline dotted;
}

.data-uri:focus,
.data-uri:focus-visible {
  outline: 2px solid #6b7280;
  outline-offset: 2px;
}

.data-uri[href=""] {
  display: none;
}

.data-uri[href=""] ~ .copy,
.data-uri[href=""] ~ .copy-message,
.data-uri[href=""] ~ .preview {
  display: none;
}

.data-uri[href=""] ~ h3 {
  display: block;
  visibility: hidden;
}

.data-uri[href=""] ~ .copy {
  display: none;
}

.data-uri ~ .copy {
  display: block;
  visibility: visible;
}

.data-uri[href=""] ~ h3::before {
  content: 'No source selected.\A\APlease select a source above.';
  white-space: pre-wrap;
  display: block;
  visibility: visible;
  margin: 0;
  padding: 3rem;
  color: #222;
  background: #f5f5f5;
  border: 1px solid #DDD;
  border-radius: var(--border-radius);
  text-align: center;
}

.preview {
  border: 1px dashed #AAA;
  width: 100%;
  min-height: 25vh;
  max-height: 100vh;
  --checker-color-light: #EEE;
  --checker-color-dark: #DDD;
  --checker-size: 20px;
  background-color: var(--checker-color-light);
  background-image:
    linear-gradient(45deg, var(--checker-color-dark) 25%, transparent 25%, transparent 75%, var(--checker-color-dark) 75%, var(--checker-color-dark)),
    linear-gradient(45deg, var(--checker-color-dark) 25%, transparent 25%, transparent 75%, var(--checker-color-dark) 75%, var(--checker-color-dark));
  background-size: var(--checker-size) var(--checker-size);
  background-position: 0 0, calc(var(--checker-size) * 0.5) calc(var(--checker-size) * 0.5);
  border-radius: var(--border-radius);
  box-shadow: 0 2px 8px rgba(30,144,255,0.07);
  margin-bottom: 1rem;
  background-color: #f5faff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.preview:hover,
.preview:focus-within {
  border-color: #6b7280;
  box-shadow: 0 2px 10px rgba(17,24,39,0.12);
}

.preview.preview-media {
  aspect-ratio: 16 / 9;
}

.preview.preview-audio {
  min-height: 6rem;
}

.preview > * {
  max-width: 100%;
  min-height: 5rem;
  max-height: 50vh;
  background: #f3f4f6;
  object-fit: contain;
  border: 0 none;
  border-radius: var(--border-radius);
  box-shadow: 0 1px 4px rgba(30,144,255,0.08);
}

.preview iframe {
  width: 100%;
  min-height: 12rem;
  height: auto;
}

.preview-placeholder {
  color: #888;
  font-size: 1.1em;
  text-align: center;
  width: 100%;
}

.help {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.9em;
  color: #374151;
}

.status-message {
  min-height: 1.25em;
  margin: 0.5rem 0 1rem;
  font-size: 0.95em;
  color: #1f2937;
}

.status-message.is-error {
  color: #1f2937;
}

.status-message.is-info {
  color: #4b5563;
}

.status-message.is-loading::before {
  content: "";
  display: inline-block;
  width: 0.75em;
  height: 0.75em;
  margin-right: 0.5em;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
  vertical-align: -0.1em;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

footer {
  text-align: center;
  color: #666;
  font-size: 0.95em;
  margin-top: 2rem;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}

.install {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  background: #374151;
  color: #fff;
  border: none;
  box-shadow: 0 2px 8px rgba(30,144,255,0.18);
  font-size: 1.1em;
  font-weight: 700;
  padding: 0.75em 1.5em;
  display: none;
  transition: background 0.2s, box-shadow 0.2s;
}

.install:hover, .install:focus {
  background: #111827;
  box-shadow: 0 4px 16px rgba(30,144,255,0.25);
}

.dropover {
  box-shadow: 0 0 0 4px #6b7280;
  border-color: #6b7280 !important;
  z-index: 2;
}

.paste-proxy {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Subtle link colors */
a, a:visited {
  color: #374151;
  text-decoration: underline;
  transition: color 0.2s;
}
a:hover, a:focus {
  color: #111827;
  text-decoration: underline;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  body {
    background: linear-gradient(135deg, #14161a 0%, #20242b 100%);
    color: #f5faff;
  }
  .sources, .output {
    background: #1f232b;
    color: #f5faff;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
    border-radius: var(--border-radius);
  }
  .sources ul {
    background: #1b1f27;
    border-radius: var(--border-radius);
  }
  input[type="url"], input[type="text"], textarea {
    background: #eeeeee;
    color: #111827;
    border-color: #64748b;
  }
  button,
  .btn-paste,
  .btn-file,
  .source-button,
  .source-action {
    background: #2a2e34;
    color: #f3f4f6;
    border-color: #6b7280;
  }
  button:hover,
  .btn-paste:hover,
  .btn-file:hover,
  .source-button:hover,
  .source-action:hover,
  button:focus,
  .btn-paste:focus,
  .btn-file:focus,
  .source-button:focus,
  .source-action:focus {
    background: #3a3f47;
    border-color: #9ca3af;
    color: #f9fafb;
  }
  .copy {
    background: #2b2f36;
    color: #e5e7eb;
    border-color: #6b7280;
  }
  .preview {
    border-color: #374151;
    border-radius: var(--border-radius);
  }
  .preview-placeholder {
    color: #b0b8c1;
  }
  .help {
    color: #d1d5db;
  }
  .status-message {
    color: #e5e7eb;
  }
  .status-message.is-error {
    color: #e5e7eb;
  }
  .status-message.is-info {
    color: #cbd5e1;
  }
  .data-uri[href=""] ~ h3::before {
    color: #f5faff;
    background: #232733;
    border: 1px solid #374151;
    border-radius: var(--border-radius);
  }
  .install {
    background: #374151;
    color: #fff;
  }
  footer {
    color: #d1d5db;
  }
  /* Subtle link colors for dark mode */
  a, a:visited {
    color: #d1d5db;
  }
  a:hover, a:focus {
    color: #f3f4f6;
  }
}

/* Success message for copy */
.copy-success {
  background: #e5e7eb !important;
  color: #111827 !important;
  border-color: #9ca3af !important;
  transition: background 0.5s, color 0.5s;
}
