:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-ring: rgba(37, 99, 235, 0.2);
  --telegram: #229ED9;
  --telegram-hover: #1b85b8;
  --accent: #8b5cf6;
  --accent-light: #f5f3ff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --radius-lg: 1rem;
  --radius-md: 0.75rem;
  --radius-sm: 0.5rem;
}

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

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Container */
.container {
  width: 100%;
  max-width: 82rem;
  margin: 0 auto;
  padding: 0 1.25rem;
  box-sizing: border-box;
}

/* Header */
header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
  width: 100%;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 4.25rem;
  padding: 0.5rem 0;
  gap: 1rem;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.logo-badge-icon {
  width: 2.5rem;
  height: 2.5rem;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 1.25rem;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
  flex-shrink: 0;
}

.logo-text {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  white-space: nowrap;
}

.logo-text span {
  color: var(--primary);
}

.tagline-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
}

.tagline-badge.new {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.tagline-badge.new .dot {
  width: 7px;
  height: 7px;
  background: #2563eb;
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* Stel.uz Ad Banner */
.ad-section {
  padding: 0.75rem 0;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  width: 100%;
}

.ad-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: linear-gradient(135deg, #f0f7ff 0%, #f5f3ff 100%);
  border: 1px solid #dbeafe;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
  width: 100%;
  gap: 1rem;
}

.ad-card:hover {
  border-color: #93c5fd;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.ad-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex: 1;
  min-width: 0;
}

.ad-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: #2563eb;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.ad-pill {
  font-size: 0.65rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #2563eb;
  background: #dbeafe;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 0.2rem;
}

.ad-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
  word-break: break-word;
}

.ad-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.35;
  word-break: break-word;
  margin-top: 0.15rem;
}

.ad-cta {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Main Area */
main {
  padding: 1.5rem 0 3.5rem 0;
  width: 100%;
}

/* Reform Feature Card */
.reform-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.reform-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.reform-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.reform-icon {
  font-size: 1.35rem;
  flex-shrink: 0;
}

.reform-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.reform-subtitle {
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-top: 0.15rem;
}

.reform-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  width: 100%;
}

.reform-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-around;
  transition: all 0.15s ease;
}

.reform-item:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.old-char {
  font-size: 1rem;
  font-weight: 600;
  color: #64748b;
  text-decoration: line-through;
  opacity: 0.75;
}

.arrow {
  color: #3b82f6;
  font-weight: bold;
  font-size: 1.1rem;
}

.new-char {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1e40af;
  background: #dbeafe;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
}

/* Control Bar */
.control-bar {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.85rem;
  width: 100%;
}

.control-left, .control-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.control-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Segmented Buttons */
.segmented-control {
  display: inline-flex;
  background: #f1f5f9;
  padding: 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid #e2e8f0;
}

.seg-btn {
  padding: 0.5rem 0.85rem;
  border: none;
  background: transparent;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  user-select: none;
}

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

.seg-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Direction Select */
.select-wrapper {
  position: relative;
  display: inline-block;
}

.select-control {
  appearance: none;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 0.55rem 2.25rem 0.55rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
  max-width: 100%;
}

.select-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.select-arrow {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #64748b;
  font-size: 0.75rem;
}

/* Converter Workspace */
.converter-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  width: 100%;
}

.converter-grid {
  display: grid;
  grid-template-columns: 1fr 50px 1fr;
  position: relative;
  width: 100%;
}

.panel {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  background: #ffffff;
  min-width: 0;
}

.panel.output-panel {
  background: #f8fafc;
  border-left: 1px solid #f1f5f9;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  min-height: 2rem;
  gap: 0.5rem;
}

.panel-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: #e2e8f0;
  color: #475569;
  white-space: nowrap;
}

.badge.detected {
  background: #dbeafe;
  color: #1e40af;
}

.panel-stats {
  font-size: 0.775rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* Textarea & Output Area */
.text-area-wrapper {
  position: relative;
  flex: 1;
  width: 100%;
}

textarea, .output-content {
  width: 100%;
  height: 20rem;
  padding: 1.15rem;
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--text-main);
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  resize: none;
  font-family: inherit;
  background: #ffffff;
  transition: all 0.15s ease;
  box-sizing: border-box;
}

textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.output-content {
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: #ffffff;
  user-select: text;
}

.output-content.placeholder {
  color: var(--text-subtle);
  font-style: italic;
}

/* Center Swap Button Divider */
.swap-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  position: relative;
  z-index: 10;
}

.swap-btn-round {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 1.15rem;
}

.swap-btn-round:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  transform: rotate(180deg) scale(1.05);
  box-shadow: var(--shadow-md);
}

.swap-btn-round:active {
  transform: rotate(180deg) scale(0.95);
}

/* Panel Actions Toolbar */
.panel-toolbar {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  width: 100%;
}

.btn-tool {
  padding: 0.55rem 0.85rem;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
  text-decoration: none;
  min-height: 2.25rem;
}

.btn-tool:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: var(--text-main);
}

.btn-tool:active {
  transform: scale(0.97);
}

.btn-tool.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

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

.btn-tool.btn-telegram {
  background: var(--telegram);
  border-color: var(--telegram);
  color: #ffffff;
}

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

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

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #0f172a;
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  z-index: 100;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: calc(100vw - 2rem);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Info & SEO Section */
.info-section {
  margin-top: 2.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.5rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.info-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: break-word;
}

.info-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 0.85rem;
  word-break: break-word;
  overflow-wrap: break-word;
}

.info-card ul {
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.info-card li {
  word-break: break-word;
  overflow-wrap: break-word;
  margin-bottom: 0.35rem;
}

.info-card kbd {
  display: inline-block;
  white-space: nowrap;
  word-break: normal;
}

/* Responsive Table Wrapper */
.table-responsive {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  display: block;
  box-sizing: border-box;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.comparison-table th, .comparison-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.comparison-table th {
  background: #f8fafc;
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
}

.comparison-table tr:last-child td {
  border-bottom: none;
}

.comparison-table tr:hover td {
  background: #f8fafc;
}

.pill-reformed {
  font-weight: 700;
  color: #1e40af;
  background: #dbeafe;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

/* Footer */
footer {
  background: #ffffff;
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  width: 100%;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ======================================================= */
/* MEDIA QUERIES: TABLETS & MOBILE PHONES                  */
/* ======================================================= */

/* Tablets / Medium Screens */
@media (max-width: 900px) {
  .converter-grid {
    grid-template-columns: 1fr;
  }
  .panel {
    padding: 1.25rem;
  }
  .panel.output-panel {
    border-left: none;
  }
  .swap-divider {
    border-left: none;
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.65rem 0;
    background: #f8fafc;
  }
  textarea, .output-content {
    height: 15rem;
  }
  .reform-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .info-section {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    gap: 1.25rem;
  }
  .info-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
    padding: 1.25rem;
  }
}

/* Mobile Screens (Under 640px) */
@media (max-width: 640px) {
  .container {
    padding: 0 0.875rem;
  }
  
  /* Header Mobile: Centered */
  .header-inner {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.85rem 0;
    gap: 0.55rem;
    min-height: auto;
    width: 100%;
  }
  .logo-group {
    justify-content: center;
    margin: 0 auto;
    text-align: center;
  }
  .logo-badge-icon {
    width: 2.25rem;
    height: 2.25rem;
    font-size: 1.1rem;
  }
  .logo-text {
    font-size: 1.25rem;
  }
  .tagline-badge {
    font-size: 0.72rem;
    padding: 0.2rem 0.55rem;
    max-width: 100%;
    white-space: normal;
    line-height: 1.35;
    justify-content: center;
    margin: 0 auto;
    text-align: center;
  }

  /* Ad Card Mobile: Stack Vertically */
  .ad-card {
    flex-direction: column;
    align-items: stretch;
    padding: 0.85rem 1rem;
    gap: 0.75rem;
  }
  .ad-left {
    width: 100%;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .ad-icon {
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
    margin-top: 0.15rem;
  }
  .ad-title {
    font-size: 0.9rem;
    line-height: 1.35;
  }
  .ad-desc {
    font-size: 0.78rem;
    line-height: 1.35;
  }
  .ad-cta {
    width: 100%;
    justify-content: center;
    padding: 0.5rem 0.85rem;
    background: #2563eb;
    color: #ffffff;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 700;
  }

  /* Reform Card Mobile */
  .reform-card {
    padding: 1rem;
  }
  .reform-title {
    font-size: 0.95rem;
  }
  .reform-subtitle {
    font-size: 0.78rem;
  }
  .reform-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  .reform-item {
    padding: 0.5rem 0.65rem;
    font-size: 0.85rem;
  }
  .new-char {
    font-size: 1rem;
    padding: 0.15rem 0.45rem;
  }

  /* Control Bar Mobile */
  .control-bar {
    padding: 0.85rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .control-left, .control-right {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
  }
  .select-wrapper {
    width: 100%;
  }
  .select-control {
    width: 100%;
    font-size: 0.825rem;
    padding: 0.6rem 2rem 0.6rem 0.75rem;
  }
  .segmented-control {
    width: 100%;
    display: flex;
  }
  .seg-btn {
    flex: 1;
    justify-content: center;
    padding: 0.5rem 0.35rem;
    font-size: 0.78rem;
  }

  /* Converter Panels Mobile */
  .panel {
    padding: 1rem 0.85rem;
  }
  textarea, .output-content {
    height: 13rem;
    font-size: 0.98rem;
    padding: 0.85rem;
  }
  .toolbar-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
    width: 100%;
  }
  .btn-tool {
    width: 100%;
    padding: 0.5rem 0.35rem;
    font-size: 0.78rem;
  }
  /* Make main actions span full width if needed */
  .panel.output-panel .toolbar-group {
    grid-template-columns: 1fr 1fr;
  }
  #copyBtn {
    grid-column: span 2;
  }

  /* Toast Mobile */
  .toast {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    max-width: calc(100vw - 2rem);
    justify-content: center;
  }

  /* Info Cards Mobile: Full width, proper padding, no overflow */
  .info-section {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    margin-top: 1.5rem;
    gap: 1rem;
  }

  .info-card {
    padding: 1.15rem 0.95rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
  }

  .info-card h3 {
    font-size: 1rem;
  }

  .info-card p, .info-card ul {
    font-size: 0.85rem;
    line-height: 1.55;
  }

  .comparison-table {
    font-size: 0.8rem;
    width: 100%;
  }

  .comparison-table th, .comparison-table td {
    padding: 0.5rem 0.4rem;
  }

  .pill-reformed {
    padding: 0.1rem 0.35rem;
    font-size: 0.75rem;
  }
}

/* Extra Small Phones (Under 360px) */
@media (max-width: 360px) {
  .container {
    padding: 0 0.5rem;
  }
  .reform-grid {
    grid-template-columns: 1fr;
  }
  .seg-btn {
    font-size: 0.72rem;
    padding: 0.4rem 0.2rem;
  }
  .toolbar-group {
    grid-template-columns: 1fr;
  }
  #copyBtn {
    grid-column: span 1;
  }
}
