:root {
  --bg: #fafafa;
  --text: #1a1a1a;
  --accent: #171717;
  --accent-hover: #333333;
  --muted: #666666;
  --placeholder: #666666;
  --border: #e5e5e5;
  --surface: #ffffff;
  --surface-hover: #f0f0f0;
  --border-hover: #d1d1d1;
  --error: #b91c1c;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --success: #15803d;
  --focus-ring: 2px solid var(--accent);
  --focus-offset: 2px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  --transition: 0.15s ease;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Layout */
.container {
  max-width: 720px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 40px 24px 32px;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  margin-bottom: 40px;
}

.logo {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--accent);
  user-select: none;
}

/* Main */
.main {
  flex: 1;
}

/* Notice Banner */
.notice-banner {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--muted);
}

.notice-banner.notice-error {
  color: var(--error);
  border-color: var(--error-border);
  background-color: var(--error-bg);
}

/* Shorten Form */
.shorten-section {
  margin-bottom: 48px;
}

.shorten-form h1 {
  margin-bottom: 16px;
  font-size: 24px;
  letter-spacing: -0.03em;
}

.input-group {
  display: flex;
  gap: 12px;
  width: 100%;
}

.url-input {
  flex: 1;
  width: 100%;
  padding: 14px 18px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color var(--transition), outline var(--transition);
  outline: none;
}

.url-input::placeholder {
  color: var(--placeholder);
}

.url-input:focus {
  border-color: var(--accent);
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

/* Alias Input */
.alias-group {
  display: flex;
  align-items: center;
  margin-top: 10px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color var(--transition), outline var(--transition);
}

.alias-group:focus-within {
  border-color: var(--accent);
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

.alias-prefix {
  padding: 12px 0 12px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
}

.alias-input {
  flex: 1;
  padding: 12px 16px 12px 2px;
  font-size: 14px;
  font-family: var(--font-mono);
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  min-width: 0;
}

.alias-input::placeholder {
  color: var(--placeholder);
  font-family: var(--font-sans);
}

.btn-primary {
  width: 100%;
  margin-top: 10px;
  background-color: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 14px 28px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--transition);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-primary:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.form-error {
  margin-top: 8px;
  font-size: 13px;
  color: var(--error);
}

/* Result Box */
.result-box {
  margin-top: 20px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: opacity var(--transition);
}

.result-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.result-tag {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
}

.result-url {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity var(--transition);
}

.result-url:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.result-original {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 4px;
}

.result-action {
  flex-shrink: 0;
}

/* Outline Buttons */
.btn-outline {
  background-color: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-outline:hover {
  background-color: var(--surface-hover);
  border-color: var(--border-hover);
}

.btn-outline:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

.btn-outline.copied {
  background-color: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

/* History Section */
.history-section {
  margin-top: 48px;
}

.history-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.history-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.history-count {
  font-size: 12px;
  color: var(--muted);
}

.history-empty {
  padding: 24px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.history-list {
  display: flex;
  flex-direction: column;
}

.history-item {
  border-top: 1px solid var(--border);
  padding: 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.history-main {
  min-width: 0;
  flex: 1;
}

.history-short-url {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  display: inline-block;
  transition: color var(--transition);
}

.history-short-url:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.history-original-url {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.history-clicks {
  font-size: 12px;
  color: var(--muted);
  min-width: 55px;
  text-align: right;
}

.history-date {
  font-size: 12px;
  color: var(--muted);
  min-width: 65px;
  text-align: right;
}

.btn-delete {
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  transition: all var(--transition);
}

.btn-delete:hover {
  color: var(--error);
  background-color: var(--error-bg);
}

.btn-delete:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

/* Footer */
.footer {
  margin-top: auto;
  padding-top: 48px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* Utility */
.hidden {
  display: none !important;
}

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

  .header {
    margin-bottom: 28px;
  }

  .input-group {
    flex-direction: column;
  }

  .alias-prefix {
    font-size: 12px;
  }

  .btn-primary {
    padding: 12px;
  }

  .result-box {
    flex-direction: column;
    align-items: flex-start;
  }

  .result-action {
    width: 100%;
  }

  .result-action .btn-outline {
    width: 100%;
    text-align: center;
  }

  .history-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .history-meta {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .history-clicks, .history-date {
    text-align: left;
    min-width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
