/* CSS Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* CSS Variables - Light Theme (Default) */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-tertiary: #e8e8ed;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted: #aeaeb2;
  --border-color: #d2d2d7;
  --accent-color: #007aff;
  --accent-hover: #0056cc;
  --accent-light: #e5f1ff;
  --success-color: #34c759;
  --error-color: #ff3b30;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-primary: #1c1c1e;
  --bg-secondary: #2c2c2e;
  --bg-tertiary: #3a3a3c;
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-muted: #636366;
  --border-color: #48484a;
  --accent-color: #0a84ff;
  --accent-hover: #409cff;
  --accent-light: #1c3a5e;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Base Styles */
html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color var(--transition), color var(--transition);
}

/* App Container */
.app {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  box-shadow: var(--shadow-md);
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  font-size: 1.75rem;
}

.title {
  font-size: 1.25rem;
  font-weight: 600;
}

.header-right {
  display: flex;
  gap: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

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

.btn-primary:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

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

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

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
}

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

.theme-icon {
  font-size: 1.25rem;
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem 0.5rem;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  min-width: 70px;
}

.tab::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background-color: var(--accent-color);
  transition: width var(--transition);
}

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

.tab.active {
  color: var(--accent-color);
}

.tab.active::after {
  width: 60%;
}

.tab-icon {
  font-size: 1.5rem;
}

/* Main Content */
.main {
  flex: 1;
  padding: 1.5rem;
}

/* Panels */
.panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.panel.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Controls */
.controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.control-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.control-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Form Elements */
input[type="number"],
input[type="text"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  transition: all var(--transition);
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-light);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236e6e73' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent-color);
  cursor: pointer;
}

/* Range Slider */
.slider-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-color);
  cursor: pointer;
  transition: transform var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-color);
  cursor: pointer;
  border: none;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Toggle Buttons */
.toggle-buttons {
  display: flex;
  gap: 0.5rem;
}

.toggle-btn {
  flex: 1;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.toggle-btn:hover {
  background-color: var(--bg-tertiary);
}

.toggle-btn.active {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
  color: white;
}

.mode-toggle {
  width: 100%;
}

/* Result Area */
.result-area {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.result-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.result-display {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  word-break: break-word;
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.result-text {
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.4;
}

.result-emoji {
  font-size: 3rem;
  letter-spacing: 0.25rem;
}

.result-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent-light);
  color: var(--accent-color);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  margin: 0.25rem;
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  70% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.emoji-caption,
.picker-comment {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 1rem;
  font-style: italic;
}

.validation-error {
  color: var(--error-color);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  min-height: 1.25rem;
}

/* Actions */
.actions {
  display: flex;
  gap: 1rem;
}

.actions .btn {
  flex: 1;
}

/* Picker Specific */
.picker-inputs {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.vs-divider {
  text-align: center;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.5rem 0;
}

/* Ad Container */
.ad-container {
  padding: 0.75rem 1rem;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-container:last-of-type {
  border-bottom: none;
  border-top: 1px solid var(--border-color);
}

.ad-container ins {
  max-width: 100%;
}

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

/* Footer */
.footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.5rem;
  margin-bottom: 0.75rem;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-links a:hover {
  color: var(--accent-color);
}

.footer-copy {
  margin: 0;
  font-size: 0.8rem;
}

/* Legal Pages */
.legal-page {
  max-width: 700px;
  margin: 0 auto;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.last-updated {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.legal-section {
  margin-bottom: 2rem;
}

.legal-section h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.legal-section p {
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.7;
}

.legal-section ul {
  color: var(--text-secondary);
  margin-left: 1.5rem;
  margin-bottom: 0.75rem;
  line-height: 1.7;
}

.legal-section li {
  margin-bottom: 0.5rem;
}

.legal-section a {
  color: var(--accent-color);
  text-decoration: none;
}

.legal-section a:hover {
  text-decoration: underline;
}

/* About Page Features */
.feature-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.feature-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.feature-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.feature-item h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.feature-item p {
  margin: 0;
  font-size: 0.9rem;
}

/* Contact Page */
.contact-email {
  font-size: 1.1rem;
}

.contact-email a {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
}

.contact-email a:hover {
  text-decoration: underline;
}

/* Logo Link */
.logo-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.logo-link:hover .title {
  color: var(--accent-color);
}

/* Animation for result appearance */
.result-display.animate {
  animation: resultPop 0.4s ease;
}

@keyframes resultPop {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Copy feedback */
.btn-secondary.copied {
  background-color: var(--success-color);
  color: white;
}

/* Responsive */
@media (max-width: 480px) {
  .header {
    padding: 0.75rem 1rem;
  }

  .title {
    font-size: 1.1rem;
  }

  .main {
    padding: 1rem;
  }

  .control-row {
    flex-direction: column;
    align-items: stretch;
  }

  .result-display {
    font-size: 2rem;
  }

  .result-emoji {
    font-size: 2.5rem;
  }

  .btn {
    padding: 0.625rem 1rem;
  }

  .slider-labels {
    font-size: 0.6rem;
  }
}

/* Medium screens and up (tablets, small laptops) */
@media (min-width: 640px) {
  .header {
    padding: 1rem 2rem;
  }

  .logo {
    font-size: 1.875rem;
  }

  .title {
    font-size: 1.35rem;
  }

  .tab {
    padding: 0.875rem 1rem;
    font-size: 0.8rem;
  }

  .tab-icon {
    font-size: 1.5rem;
  }

  .main {
    padding: 2rem 2.5rem;
  }

  .result-area {
    padding: 2rem;
  }

  .result-display {
    font-size: 2.75rem;
    min-height: 4rem;
  }

  .result-text {
    font-size: 1.35rem;
  }

  .result-emoji {
    font-size: 3.25rem;
  }

  .result-number {
    padding: 0.5rem 1rem;
    font-size: 1.1rem;
  }

  .btn {
    padding: 0.875rem 1.75rem;
  }
}

/* Large screens (PC) */
@media (min-width: 900px) {
  .header {
    padding: 1rem 2.5rem;
  }

  .main {
    padding: 2rem 3rem;
  }

  .controls {
    gap: 1.25rem;
  }

  .result-area {
    padding: 2.25rem;
  }

  .result-display {
    font-size: 3rem;
    min-height: 4.5rem;
  }

  .result-text {
    font-size: 1.5rem;
    line-height: 1.5;
  }

  .result-emoji {
    font-size: 3.5rem;
    letter-spacing: 0.4rem;
  }

  .emoji-caption,
  .picker-comment {
    font-size: 0.95rem;
  }

  .slider-labels {
    font-size: 0.75rem;
  }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
