:root {
  --bg: #FAFAF8;
  --text: #111;
  --accent: #FF3E00;
  --muted: #999;
  --border: #E5E5E3;
  --surface: #FFF;
  --radius: 8px;
  --font: 'Space Grotesk', sans-serif;
  --mono: 'Space Mono', monospace;
}

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

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  background-image: radial-gradient(circle, #ddd 1px, transparent 1px);
  background-size: 24px 24px;
}

/* Views */
.view { display: none; min-height: 100vh; }
.view.active { display: block; }

/* Welcome */
.welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.brand {
  font-size: 72px;
  font-weight: 700;
  letter-spacing: -3px;
  color: var(--text);
  line-height: 1;
}

.brand .dot { color: var(--accent); }

.tagline {
  font-size: 18px;
  color: var(--muted);
  margin: 12px 0 48px;
  letter-spacing: 1px;
}

.username-form {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 440px;
}

.username-form input {
  flex: 1;
}

/* Inputs */
input[type="text"],
input[type="url"] {
  font-family: var(--mono);
  font-size: 14px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

input:focus {
  border-color: var(--accent);
}

input::placeholder {
  color: var(--muted);
  font-family: var(--font);
}

/* Buttons */
.btn {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
}

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

.btn-ghost {
  background: none;
  color: var(--muted);
  padding: 8px 16px;
}

.btn-ghost:hover {
  color: var(--text);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  opacity: 0.9;
}

/* Icon buttons */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  padding: 0;
}

.btn-icon:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.btn-icon-danger:hover {
  color: #e00;
  border-color: #e00;
}

.btn-icon svg {
  display: block;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}

.tab:hover {
  color: var(--text);
  border-color: var(--text);
}

.tab.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(250, 250, 248, 0.9);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-sm {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  cursor: pointer;
  color: var(--text);
}

.brand-sm:hover { color: var(--accent); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.username-badge {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  background: var(--surface);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* Dashboard */
.dashboard-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px;
}

.shorten-section {
  margin-bottom: 64px;
}

.shorten-section h2,
.urls-section h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  letter-spacing: -0.5px;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input[type="url"] {
  flex: 2;
}

.input-row input[type="text"] {
  flex: 1;
  min-width: 140px;
}

.shorten-result {
  margin-top: 16px;
  padding: 16px 20px;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideUp 0.3s ease;
}

.result-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.result-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.shorten-result .short-url {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shorten-result .short-url:hover {
  text-decoration: underline;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.error-msg {
  margin-top: 12px;
  padding: 12px 16px;
  background: #FFF5F5;
  border: 1px solid #FCC;
  border-radius: var(--radius);
  color: #C00;
  font-size: 14px;
}

.hidden { display: none !important; }

/* URL List */
.urls-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-state {
  color: var(--muted);
  font-size: 15px;
  text-align: center;
  padding: 48px 0;
}

.url-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 0.2s;
  animation: slideUp 0.3s ease backwards;
}

.url-card:hover {
  border-color: var(--accent);
}

.url-card .favicon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  flex-shrink: 0;
}

.url-card-info {
  flex: 1;
  min-width: 0;
}

.url-card-original {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.url-card-code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  display: inline-block;
  margin-top: 2px;
}

a.url-card-code:hover {
  text-decoration: underline;
}

.owner-badge {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.url-card-title {
  font-size: 13px;
  color: var(--text);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.url-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.click-count {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
  transition: all 0.15s;
}

.click-count:hover {
  background: var(--bg);
  color: var(--accent);
}

.copy-feedback {
  font-size: 12px;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}

.copy-feedback.show {
  opacity: 1;
}

/* Analytics */
.analytics-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px;
}

.analytics-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 24px;
}

.analytics-header {
  margin-bottom: 32px;
}

.analytics-header h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.analytics-header .original-url {
  font-size: 14px;
  color: var(--muted);
  word-break: break-all;
}

.analytics-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card .stat-value {
  font-family: var(--mono);
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.recent-clicks h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.click-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.click-item {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: slideUp 0.2s ease backwards;
}

.click-item .click-time {
  color: var(--accent);
  font-weight: 700;
}

.click-item .click-ago {
  color: var(--muted);
  margin-left: 12px;
}

.loading {
  text-align: center;
  padding: 48px;
  color: var(--muted);
}

/* Animations */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive */
@media (max-width: 600px) {
  .brand { font-size: 56px; }
  .input-row { flex-direction: column; }
  .topbar { padding: 12px 16px; }
  .dashboard-main { padding: 32px 16px; }
  .analytics-stats { grid-template-columns: 1fr; }
  .url-card { flex-direction: column; align-items: flex-start; }
  .url-card-actions { width: 100%; justify-content: flex-end; }
}
