:root {
  --bg: #f6f8fa;
  --card: #fff;
  --accent: #0067c5;
  --muted: #6b7280;

  --spacing: 0.25rem;
}

* {
  box-sizing: border-box;
}

/* Ensure hidden attribute is always respected */
[hidden] {
  display: none !important;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: #111;
  margin: 0;
  padding: 24px;
  /* reserve space for the fixed classification bars */
  padding-top: calc(24px + 32px);
  padding-bottom: calc(24px + 32px);
}

.classification {
  display: block;
  unicode-bidi: isolate;
  text-align: center;

  color: #fff;
  font-size: 16px;
  left: 0;
  right: 0;
  flex-shrink: 0;
  background: #3d1e5a;
  z-index: 20;
  font-weight: 400;
  padding: calc(var(--spacing) * 0);
  -webkit-font-smoothing: antialiased;
  height: calc(var(--spacing) * 8);

  position: fixed;
}

header.classification { top: 0 }
footer.classification { bottom: 0 }

.container {
  max-width: 760px;
  margin: 0 auto;
  background: var(--card);
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(2, 6, 23, 0.06);
}

h1 {
  margin: 0 0 14px;
  font-size: 20px;
}

.url-row, .optional-row, .result-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.prefix {
  background: #f0f3f7;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #e6eef9;
  color: var(--muted);
  font-weight: 600;
  flex: 0 0 auto;
  min-width: 0;
}

input[type="text"],
input[type="url"],
input[type="date"],
input[type="number"] {
  flex: 1;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  min-width: 0;
}

.url-label, .expiryDateLabel, .visitLimitLabel {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.action {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  justify-content: flex-end;
}

button {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

#copyUrl {
  background: #e5e7eb;
  color: #111;
  padding: 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.result-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}

.copied {
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}

.notes {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.notes code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Prevent horizontal overflow on narrow screens */
h1,
.prefix,
.notes,
.url-label,
.expiryDateLabel,
.visitLimitLabel,
#copied {
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
  min-width: 0;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .container {
    padding: 14px;
  }

  /* Stack rows vertically on narrow screens */
  .url-row,
  .optional-row,
  .result-row {
    flex-direction: column;
    align-items: stretch;
  }

 .prefix,
 .url-label,
 .expiryDateLabel,
 .visitLimitLabel {
    width: 100%;
    margin-bottom: 6px;
  }

  .url-row input,
  .optional-row input,
  .result-row input {
    width: 100%;
  }

  /* Make action buttons span full width and flow under inputs */
  .action {
    justify-content: flex-start;
  }

  /* Slightly smaller clear buttons on narrow screens */
  #shortenUrl {
    padding: 6px 8px;
  }

  button {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
  }

  .copy-row,
  .feedback {
    justify-content: flex-start;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  /* keep the "Copied!" feedback aligned to the right on narrow screens */
  .copied {
    align-self: flex-end;
    text-align: right;
    width: auto;
  }
}

/* ensure prefix and clear button don't force overflow in horizontal layouts */
.prefix,
#shortenUrl {
  flex: 0 0 auto;
}

.feedback {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

.feedback button {
  background: #e5e7eb;
  color: #111;
  border: 1px solid #d1d5db;
}