:root{
  /* Dark mode colors (default) */
  --bg:#0b0d10;
  --card:#12161b;
  --muted:#98a2b3;
  --text:#e5e7eb;
  --accent:#4f46e5;
  --accent-2:#22c55e;
  --danger:#ef4444;
  --border:#1f2937;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 16px;
  --radius-sm: 12px;
  --card-gradient-1: rgba(79,70,229,.08);
  --card-gradient-2: rgba(34,197,94,.08);
  --input-bg: #0f1318;
  --input-focus-bg: #0a0e12;
  --code-bg: #0f1318;
  --hover-bg: #141920;
  --btn-bg-1: #202735;
  --btn-bg-2: #1a2230;
}

[data-theme="light"] {
  /* Light mode colors */
  --bg: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  --card: #ffffff;
  --muted: #64748b;
  --text: #1e293b;
  --accent: #4f46e5;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --border: #e2e8f0;
  --shadow: 0 10px 30px rgba(0,0,0,.08);
  --card-gradient-1: rgba(79,70,229,.04);
  --card-gradient-2: rgba(34,197,94,.04);
  --input-bg: #f8fafc;
  --input-focus-bg: #ffffff;
  --code-bg: #f8fafc;
  --hover-bg: #f1f5f9;
  --btn-bg-1: #475569;
  --btn-bg-2: #334155;
}

/* Auto theme based on system preference */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    --card: #ffffff;
    --muted: #64748b;
    --text: #1e293b;
    --accent: #4f46e5;
    --accent-2: #22c55e;
    --danger: #ef4444;
    --border: #e2e8f0;
    --shadow: 0 10px 30px rgba(0,0,0,.08);
    --card-gradient-1: rgba(79,70,229,.04);
    --card-gradient-2: rgba(34,197,94,.04);
    --input-bg: #f8fafc;
    --input-focus-bg: #ffffff;
    --code-bg: #f8fafc;
    --hover-bg: #f1f5f9;
    --btn-bg-1: #e2e8f0;
    --btn-bg-2: #cbd5e1;
  }
}

*{box-sizing:border-box}

/* Animations */
@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

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

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes success {
  0% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.1) rotate(5deg); }
  50% { transform: scale(1.1) rotate(-5deg); }
  75% { transform: scale(1.1) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); }
}
html,body{height:100%}
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font:16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Default dark background */
:root body {
  background:linear-gradient(180deg,#0b0d10 0%, #0e1217 100%);
}

[data-theme="light"] body {
  background:linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.app-header{
  padding:24px 20px 10px;
  max-width:1100px;
  margin:0 auto;
}
h1{
  margin:0;
  font-size:28px;
  letter-spacing:.5px;
  text-align:center;
}
.sub{font-size:.7em; color:var(--muted); margin-left:.5rem}

.tool-description {
  margin: 8px 0 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  font-weight: 400;
}

[data-theme="light"] .tool-description {
  color: #64748b;
}

.tabs{
  margin-top:14px;
  display:flex;
  gap:8px;
  justify-content:center;
}
.tab{
  background:transparent;
  color:var(--muted);
  border:1px solid var(--border);
  padding:10px 14px;
  border-radius:999px;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:6px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.tab:hover:not(.active) {
  background: rgba(79,70,229,0.1);
  border-color: rgba(79,70,229,0.3);
  transform: translateY(-2px);
}

[data-theme="light"] .tab:not(.active) {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #475569;
}

[data-theme="light"] .tab:hover:not(.active) {
  background: rgba(79,70,229,0.05);
  border-color: var(--accent);
  color: var(--accent);
}
.tab svg {
  width: 16px;
  height: 16px;
  transition: transform 0.3s ease;
}
.tab:hover svg {
  transform: rotate(5deg);
}
.tab.active{
  color:#fff;
  border-color:transparent;
  background:linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  box-shadow:0 6px 20px rgba(79,70,229,.35);
  animation: fadeIn 0.5s ease;
}
.tab.active svg {
  transform: rotate(0deg);
}

main{
  padding: 8px 20px 24px;
  max-width:1100px;
  margin:0 auto;
}

.panel{
  display:block;
  animation: fadeIn 0.4s ease;
}
.panel[hidden]{display:none}

.grid{
  display:grid;
  gap:16px;
}
.grid-2{grid-template-columns:1fr 1fr}
@media (max-width: 980px){
  .grid-2{grid-template-columns:1fr}
}

@media (max-width: 640px) {
  .app-header h1 {
    font-size: 24px;
  }
  .tabs {
    flex-wrap: wrap;
  }
  .tab {
    flex: 1;
    min-width: 140px;
  }
  .controls-inline {
    flex-wrap: wrap;
  }
  .options {
    flex-direction: column;
    gap: 8px;
  }
  .field, .toggle {
    width: 100%;
  }
  .btn.primary {
    width: 100%;
    justify-content: center;
  }
  .table-wrap {
    margin: 0 -8px;
  }
  .table {
    font-size: 14px;
  }
  .table th:nth-child(2),
  .table td:nth-child(2) {
    min-width: 80px;
  }
}

.card{
  background: radial-gradient(1200px 400px at -10% -50%, var(--card-gradient-1), transparent 50%),
              radial-gradient(1000px 600px at 120% 0%, var(--card-gradient-2), transparent 45%),
              var(--card);
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding:20px;
  margin-bottom:24px;
  transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 40px rgba(0,0,0,.4);
}
.card-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:8px;
}
.card h2,.card h3{margin:0}

.controls-inline{
  display:flex;
  gap:12px;
  align-items:center;
  flex-wrap: wrap;
}

.preset-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

textarea{
  width:100%;
  min-height:200px;
  background:var(--input-bg);
  color:var(--text);
  border:1px solid var(--border);
  border-radius:12px;
  padding:12px;
  resize:vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Noto Sans Mono", monospace;
  transition: border-color 0.3s ease, background 0.3s ease, color 0.3s ease;
}
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--input-focus-bg);
}
textarea.highlight-change {
  animation: pulse 0.4s ease;
}
textarea[readonly]{opacity:.9}

.hint{
  color:var(--muted);
  font-size:.92rem;
  margin-top:8px;
}

.mt{margin-top:16px}

.options{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:12px 16px;
}

.toggle{
  display:flex;
  align-items:center;
  gap:8px;
  color:var(--text);
  background:var(--input-bg);
  border:1px solid var(--border);
  padding:8px 12px;
  border-radius:999px;
}
.toggle input{
  accent-color: var(--accent);
  cursor: pointer;
}

[data-theme="light"] input[type="checkbox"] {
  accent-color: var(--accent);
  transform: scale(1.1);
}

[data-theme="light"] .table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.toggle:hover {
  background: var(--hover-bg);
  transform: translateY(-1px);
}
.toggle {
  transition: all 0.2s ease;
  cursor: pointer;
}

.field{
  display:flex;
  align-items:center;
  gap:8px;
  background:var(--input-bg);
  border:1px solid var(--border);
  padding:8px 12px;
  border-radius:999px;
}
.field > span{color:var(--muted)}
.field input,.field select{
  background:transparent;
  color:var(--text);
  border:none;
  outline:none;
  min-width:160px;
}

/* Select styling for better visibility */
.field select {
  cursor: pointer;
  padding-right: 20px;
  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='%2398a2b3' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  background-size: 12px;
}

.field select:hover {
  color: var(--accent);
}

/* Select dropdown styling for better visibility */
.field select option {
  background: var(--card);
  color: var(--text);
  padding: 8px;
}

/* Dark mode specific select styling */
:root .field select option {
  background: #1a1f26;
  color: #e5e7eb;
}

:root .field select:focus {
  color: #ffffff;
}

/* Light mode specific select styling */
[data-theme="light"] .field select option {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid var(--border);
}

/* Special styling for default/placeholder option */
.field select option[value=""] {
  color: var(--muted);
  font-style: italic;
}

[data-theme="light"] .field select option[value=""] {
  color: #94a3b8;
}

/* Ensure select shows proper text color when no option is selected */
.field select:invalid {
  color: var(--muted);
}

[data-theme="light"] .field select:invalid {
  color: #94a3b8;
}

[data-theme="light"] .field select {
  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='%2364748b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}
.field {
  transition: all 0.2s ease;
}
.field:hover:not(.disabled) {
  background: var(--hover-bg);
  transform: translateY(-1px);
}
.field.disabled {
  opacity: 0.5;
  pointer-events: none;
}
.field input:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.spacer{flex:1}

.btn{
  background:linear-gradient(135deg, var(--btn-bg-1), var(--btn-bg-2));
  color:var(--text);
  border:1px solid var(--border);
  border-radius:999px;
  padding:8px 14px;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  gap:6px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

[data-theme="light"] .btn {
  background:linear-gradient(135deg, #475569, #334155);
  color: #ffffff;
  border-color: #cbd5e1;
}

[data-theme="light"] .btn:hover {
  background:linear-gradient(135deg, #334155, #1e293b);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.btn svg {
  width: 14px;
  height: 14px;
  transition: transform 0.3s ease;
}
.btn:hover{
  filter:brightness(1.15);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.btn:hover svg {
  transform: rotate(10deg) scale(1.1);
}
.btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.btn.success {
  animation: success 0.5s ease;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.btn.primary{
  background:linear-gradient(135deg, var(--accent), #7c3aed);
  border-color:transparent;
  box-shadow:0 6px 20px rgba(79,70,229,.35);
  color: #fff;
}
.btn.primary:hover {
  box-shadow:0 8px 25px rgba(79,70,229,.45);
}
.btn.primary.pulse {
  animation: pulse 0.6s ease;
}
.btn.ghost{
  background:transparent;
  border:1px solid var(--border);
}

[data-theme="light"] .btn.ghost {
  background: transparent;
  color: #475569;
  border-color: #cbd5e1;
}

[data-theme="light"] .btn.ghost:hover {
  background: rgba(79,70,229,0.08);
  border-color: var(--accent);
  color: var(--accent);
}
.btn.danger{background:linear-gradient(135deg, #b91c1c, #ef4444)}
.btn.danger.ghost{
  background:transparent;
  color:#ffbdbd;
  border-color:#6b1d1d;
}

[data-theme="light"] .btn.danger {
  background:linear-gradient(135deg, #dc2626, #ef4444);
  color: #ffffff;
}

[data-theme="light"] .btn.danger.ghost {
  background: transparent;
  color: #dc2626;
  border-color: #fecaca;
}

[data-theme="light"] .btn.danger.ghost:hover {
  background: rgba(239,68,68,0.1);
  border-color: #ef4444;
}
.btn.xs{
  padding:4px 10px;
  font-size:.9rem;
}

[data-theme="light"] .btn.xs {
  font-weight: 500;
}

.table-wrap{
  overflow:auto;
  margin:16px 0;
}
.table{
  width:100%;
  border-collapse:collapse;
  border:1px solid var(--border);
  border-radius:8px;
  overflow:hidden;
}
.table th,.table td{
  padding:10px 12px;
  border-right:1px solid var(--border);
  vertical-align:top;
  background:var(--card);
}
.table th{
  border-bottom:2px solid var(--border);
  font-weight:600;
}
.table th:last-child,
.table td:last-child{
  border-right:none;
}
.table tbody tr{
  border-bottom:1px solid var(--border);
}
.table tbody tr:last-child{
  border-bottom:none;
}

[data-theme="light"] .table td {
  color: var(--text);
}
.table th{
  color:#cbd5e1;
  text-align:left;
  white-space:nowrap;
}

[data-theme="light"] .table th {
  color: #475569;
  font-weight: 600;
  background: #f8fafc;
}
[data-theme="light"] .table td {
  background: #ffffff;
}
.center{text-align:center}
.table .cell-key{
  text-align:center;
  vertical-align:middle !important;
  display:table-cell !important;
  min-height:48px;
  line-height:1.4;
  padding:12px 8px;
}
.mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Noto Sans Mono", monospace;
}

[data-theme="light"] .mono {
  color: #0f172a;
  font-weight: 500;
  background: #f0f9ff;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Word keys styling */
.word-key {
  background: linear-gradient(135deg, #34d399, #22c55e);
  color: #ffffff;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

[data-theme="light"] .word-key {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.12);
}

/* Guide/座学 tab specific styles */
.guide-container {
  display: flex;
  flex-direction: column;
  gap: 32px;
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 0;
}

.guide-content {
  padding: 16px 0;
  line-height: 1.6;
}

.guide-content p {
  margin-bottom: 16px;
  color: var(--text);
}

/* Timeline styles */
.timeline {
  position: relative;
  padding-left: 32px;
  margin: 24px 0;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--accent), var(--accent-secondary));
}

.timeline-item {
  position: relative;
  margin-bottom: 24px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -26px;
  top: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--card);
  box-shadow: 0 0 0 2px var(--accent);
}

.timeline-year {
  font-weight: 600;
  color: var(--accent);
  font-size: 14px;
  min-width: 80px;
  padding-top: 2px;
}

.timeline-content h4 {
  margin: 0 0 4px 0;
  font-size: 16px;
  color: var(--text);
}

.timeline-content p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* Conversion rules styles */
.conversion-rules {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.rule-category h4 {
  margin: 0 0 16px 0;
  color: var(--text);
  font-size: 18px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.rule-item {
  display: grid;
  grid-template-columns: 40px 30px 100px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.rule-item:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.rule-item .char {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px;
}

.rule-item .arrow {
  color: var(--accent);
  font-size: 16px;
  text-align: center;
}

.rule-item .leet {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
}

.rule-item .reason {
  font-size: 13px;
  color: var(--muted);
}

/* Use cases styles */
.use-cases {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.use-case {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 20px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.2s ease;
}

.use-case:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.use-case-icon {
  font-size: 24px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  flex-shrink: 0;
}

.use-case-icon.security {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.use-case-icon.education {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.use-case-icon.communication {
  background: linear-gradient(135deg, #10b981, #059669);
}

.use-case-content h4 {
  margin: 0 0 12px 0;
  color: var(--text);
  font-size: 18px;
}

.use-case-content ul {
  margin: 0;
  padding-left: 20px;
  list-style: none;
}

.use-case-content li {
  position: relative;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.use-case-content li::before {
  content: '▸';
  color: var(--accent);
  position: absolute;
  left: -16px;
}

.use-case-content strong {
  color: var(--text);
}

/* Best practices styles */
.best-practices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 24px;
}

.practice-section h4 {
  margin: 0 0 16px 0;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.practice-section ul {
  margin: 0;
  padding-left: 20px;
  list-style: none;
}

.practice-section li {
  position: relative;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.warning-list li::before {
  content: '⚠️';
  position: absolute;
  left: -20px;
}

.tip-list li::before {
  content: '✅';
  position: absolute;
  left: -20px;
}

.practice-section strong {
  color: var(--text);
}

/* Light theme adjustments for guide */
[data-theme="light"] .guide-content p,
[data-theme="light"] .timeline-content h4,
[data-theme="light"] .rule-item .char,
[data-theme="light"] .use-case-content h4,
[data-theme="light"] .practice-section h4,
[data-theme="light"] .practice-section strong,
[data-theme="light"] .use-case-content strong {
  color: #1e293b;
}

[data-theme="light"] .timeline-content p,
[data-theme="light"] .rule-item .reason,
[data-theme="light"] .use-case-content li,
[data-theme="light"] .practice-section li {
  color: #64748b;
}

[data-theme="light"] .rule-item,
[data-theme="light"] .use-case {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .rule-item:hover,
[data-theme="light"] .use-case:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .guide-container {
    padding: 0 8px;
  }

  .rule-grid {
    grid-template-columns: 1fr;
  }

  .rule-item {
    grid-template-columns: 30px 20px 80px 1fr;
    gap: 8px;
    padding: 8px 12px;
  }

  .rule-item .char {
    font-size: 16px;
  }

  .rule-item .leet {
    font-size: 14px;
  }

  .rule-item .reason {
    font-size: 12px;
  }

  .use-case {
    flex-direction: column;
    text-align: center;
  }

  .use-case-icon {
    align-self: center;
  }

  .best-practices {
    grid-template-columns: 1fr;
  }

  .timeline {
    padding-left: 24px;
  }

  .timeline-item::before {
    left: -20px;
  }
}

/* Alternative checkboxes styling */
.alternatives-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
  min-height: 32px;
  align-content: flex-start;
}

.alt-item {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  transition: all 0.2s ease;
}

.alt-item:hover {
  background: var(--hover-bg);
}

.alt-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
}

.alt-item .alt-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.alt-item.disabled {
  opacity: 0.6;
}

.alt-item.disabled .alt-value {
  color: var(--muted);
}

.file-label{
  position:relative;
}
.file-label input{
  position:absolute;
  inset:0;
  opacity:0;
  cursor:pointer;
}

[data-theme="light"] .file-label {
  color: #475569;
}

[data-theme="light"] .file-label:hover {
  color: var(--accent);
}

dialog{
  border:none;
  border-radius: var(--radius-sm);
  padding:0;
  background: var(--card);
  color:var(--text);
  box-shadow: var(--shadow);
}
dialog::backdrop{
  background:rgba(0,0,0,.65);
}
[data-theme="light"] .dialog-card {
  background: #ffffff;
  border: 1px solid var(--border);
}

.dialog-card{
  padding:16px;
  min-width: min(540px, 92vw);
  animation: slideDown 0.3s ease;
}
.dialog-body{display:grid; gap:12px; margin:12px 0}
.dialog-actions{
  display:flex; justify-content:flex-end; gap:8px;
}
.error{
  color:#ff9aa2;
  min-height:1.2em;
  transition: all 0.3s ease;
}

/* Preset dialog specific styles */
.preset-info {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.preset-icon {
  color: var(--accent);
  flex-shrink: 0;
}

.preset-details h4 {
  margin: 0 0 4px 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
}

.preset-details p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.preset-warning {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px;
  background: rgba(251, 146, 60, 0.1);
  border: 1px solid rgba(251, 146, 60, 0.3);
  border-radius: 8px;
  margin-bottom: 16px;
}

.preset-warning svg {
  color: #f59e0b;
  flex-shrink: 0;
}

.preset-warning span {
  color: var(--text);
  font-size: 14px;
}

[data-theme="light"] .preset-warning {
  background: rgba(251, 146, 60, 0.05);
  border-color: rgba(251, 146, 60, 0.2);
}

.preset-stats {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat-label {
  color: var(--muted);
  font-size: 14px;
}

.stat-value {
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  background: var(--accent);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 12px;
  min-width: 24px;
  text-align: center;
}

/* Diff view styles */
.diff-view {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: stretch;
  margin-top: 12px;
  animation: fadeIn 0.4s ease;
}
.diff-arrow {
  color: var(--accent);
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.diff-text {
  padding: 12px;
  background: var(--code-bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  min-height: 80px;
  word-break: break-all;
  white-space: pre-wrap;
  color: var(--text);
}
.diff-text.original {
  border-color: var(--border);
}
.diff-text.converted {
  border-color: var(--accent);
  background: linear-gradient(90deg, var(--code-bg), rgba(79,70,229,0.05));
}

/* Highlighted character */
.char-highlight {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  padding: 2px 4px;
  border-radius: 4px;
  font-weight: bold;
  margin: 0 1px;
  display: inline-block;
  animation: pulse 2s ease infinite;
}

/* Theme toggle button styles */
.theme-toggle {
  position: absolute;
  top: 24px;
  right: calc(50% - 550px); /* Align with 1100px max-width content */
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: var(--shadow);
}

/* Responsive positioning */
@media (max-width: 1140px) {
  .theme-toggle {
    right: 20px;
  }
}

.theme-toggle:hover {
  transform: scale(1.1) rotate(10deg);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  color: var(--text);
  display: block;
}

/* Dark mode: show sun icon (to switch to light) */
.theme-toggle .sun-icon {
  display: block;
}

.theme-toggle .moon-icon {
  display: none;
}

/* Light mode: show moon icon (to switch to dark) */
[data-theme="light"] .theme-toggle .sun-icon {
  display: none;
}

[data-theme="light"] .theme-toggle .moon-icon {
  display: block;
}

.diff-toggle {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .diff-view {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .diff-arrow {
    transform: rotate(90deg);
    font-size: 20px;
  }
}


footer{
  padding:8px 24px 24px;
  color:var(--muted);
  text-align:center;
}
.footer a{color:#9ac1ff; text-decoration:none}
.footer a:hover{text-decoration:underline}
