/* ===================================================================
   UUID Generator — earth87human (cream surface, tomato accent)
   Bezel screen display, preset chips, format toggles, bulk output.
   =================================================================== */

/* ============ Design tokens ============ */
:root {
  --bg: #faf6f1;
  --bg-2: #f3eee5;
  --surface: #ffffff;
  --surface-2: #faf6ed;
  --surface-3: #eee7d8;
  --border: #e8dfcc;
  --border-soft: #f0e9da;
  --text: #1f1a14;
  --text-2: #5c5547;
  --text-3: #6e6557;
  --text-faint: #b5ac9b;
  --accent: #e85f4d;
  --accent-2: #d44a39;
  --accent-soft: rgba(232, 95, 77, 0.10);
  --accent-glow: rgba(232, 95, 77, 0.30);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 24px 48px rgba(0,0,0,0.12);

  --font-ui: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
             "PingFang TC", "PingFang SC", "Hiragino Sans", "Noto Sans CJK",
             sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ Reset ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
html, body {
  font-family: var(--font-ui);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 235, 220, 0.55) 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "ss01" 1;
  line-height: 1.55;
  touch-action: manipulation;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-2); }
ul, ol { list-style: none; }
[hidden] { display: none !important; }

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px; top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
  border-radius: 0 0 var(--r-sm) 0;
  z-index: 1000;
}
.skip-link:focus { left: 0; }

/* ============ App layout ============ */
.app {
  max-width: 600px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 24px) clamp(12px, 3vw, 24px) 80px;
}

/* ============ Top bar ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 28px;
}
.brand {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text-2);
}
.brand:hover { color: var(--accent); }

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

.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
@media (max-width: 380px) {
  .nav-link { font-size: 12px; padding: 4px 8px; }
}
.nav-link:hover { color: var(--accent); background: var(--surface-2); }

.lang-switcher {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%237a7973' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  transition: border-color var(--transition);
}
.lang-switcher:hover { border-color: var(--text-3); }
.lang-switcher:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }

/* ============ Page title ============ */
.page-title {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 6px;
}
.page-sub {
  text-align: center;
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 36px;
}

/* ============ Workspace ============ */
.workspace {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 64px;
}

/* ============ Output card (light Tomato Hero) ============ */
.device {
  margin: 0 auto;
  max-width: 560px;
  width: 100%;
}

.device-bezel {
  position: relative;
  border-radius: var(--r-xl);
  padding: clamp(16px, 3vw, 24px);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

/* Output panel → light recessed cream */
.device-screen {
  position: relative;
  border-radius: var(--r-lg);
  padding: clamp(16px, 4vw, 28px) clamp(14px, 3vw, 24px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
  overflow: hidden;
}

.screen-glare { display: none; }

/* UUID display */
.uuid-display {
  position: relative;
  z-index: 1;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  word-break: break-all;
}

.uuid-text {
  font-family: var(--font-mono);
  font-size: clamp(14px, 2.8vw, 18px);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
  text-align: center;
  line-height: 1.4;
  transition: all var(--transition);
}

.uuid-text.is-placeholder {
  color: var(--text-3);
  font-size: 13px;
  letter-spacing: 0.03em;
  font-weight: 400;
}

/* Screen action buttons */
.screen-actions {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.screen-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  min-height: 44px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.screen-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.screen-btn:active {
  background: var(--surface-2);
}
.screen-btn.is-copied {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ============ Device brand (removed in light theme) ============ */
.device-brand { display: none; }

/* ============ Controls ============ */
.controls {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.control-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-3);
  font-weight: 600;
  margin-bottom: 2px;
}

/* Count chips */
.count-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.chip {
  padding: 8px 14px;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.chip-active:hover { color: #fff; }

/* ============ Toggle switches ============ */
.toggle-list {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.toggle-row:hover {
  border-color: var(--text-3);
  background: var(--surface-2);
}

.toggle-label {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  user-select: none;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  transition: background var(--transition);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
}
.toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15), 0 1px 0 rgba(0,0,0,0.05);
  transition: transform var(--transition);
}

.toggle-input:checked + .toggle-track {
  background: linear-gradient(180deg, #ee6e5d 0%, var(--accent-2) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
}
.toggle-input:checked + .toggle-track::after {
  transform: translateX(18px);
}

.toggle-input:focus-visible + .toggle-track {
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* ============ Action row ============ */
.action-row {
  display: flex;
  justify-content: center;
  padding-top: 4px;
}

.btn-generate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 40px;
  background: linear-gradient(180deg, #ee6e5d 0%, var(--accent-2) 100%);
  color: #fff;
  border-radius: var(--r-pill);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
  min-width: 200px;
  transition: background var(--transition), transform 80ms ease-out, box-shadow var(--transition);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.4),
    inset 0 -1px 0 rgba(0,0,0,0.12),
    0 4px 12px var(--accent-glow),
    0 1px 2px rgba(0,0,0,0.08);
}
.btn-generate:hover {
  background: linear-gradient(180deg, #f07866 0%, #de5141 100%);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.45),
    inset 0 -1px 0 rgba(0,0,0,0.12),
    0 6px 16px var(--accent-glow),
    0 1px 2px rgba(0,0,0,0.08);
}
.btn-generate:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,0.22),
    0 1px 2px var(--accent-glow);
}
.btn-generate.is-pressed {
  transform: scale(0.96);
  opacity: 0.85;
}

/* ============ Bulk output ============ */
.bulk-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bulk-output {
  width: 100%;
  min-height: 120px;
  padding: clamp(16px, 3vw, 24px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
  white-space: pre;
  overflow-x: auto;
  tab-size: 4;
}
.bulk-output:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.bulk-actions {
  display: flex;
  justify-content: flex-end;
}

.btn-copy-bulk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  min-height: 44px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.btn-copy-bulk:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.btn-copy-bulk.is-copied {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ============ Info / SEO section ============ */
.info {
  max-width: 720px;
  margin: 40px auto 0;
  padding: 0 4px;
  color: var(--text-2);
  line-height: 1.7;
}
.info h2 {
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  margin: 26px 0 10px;
}
.info h2:first-child { margin-top: 0; }
.info p { margin-bottom: 10px; font-size: 15px; }

/* ============ Footer ============ */
.site-footer {
  max-width: 720px;
  margin: 56px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}
.site-footer-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 6px;
}
.site-footer a { color: var(--text-2); }
.site-footer a:hover { color: var(--accent); }
.site-footer .sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 8px;
}

/* ============ Responsive ============ */
@media (max-width: 600px) {
  .app { padding: 8px 12px 60px; }
  .topbar { padding: 4px 0 20px; }
  .lang-switcher { padding: 4px 22px 4px 8px; font-size: 12px; max-width: 140px; }
  .page-title { margin-bottom: 4px; }
  .page-sub { margin-bottom: 24px; }
  .device-bezel { padding: 16px 14px; border-radius: var(--r-lg); }
  .device-screen { border-radius: var(--r-md); padding: 14px 10px; }
  .uuid-text { font-size: 13px; }
  .uuid-text.is-placeholder { font-size: 12px; }
  .btn-generate { padding: 14px 32px; font-size: 16px; min-width: 180px; }
  .chip { padding: 7px 12px; font-size: 13px; }
  .toggle-row { padding: 8px 12px; }
  .toggle-label { font-size: 13px; }
  .info { padding: 16px 4px; }
  .info h2 { font-size: 20px; margin-top: 28px; }
}

@media (max-width: 420px) {
  .topbar-right .nav-link { display: none; }
  .topbar-right { gap: 6px; }
  .lang-switcher { max-width: 130px; }
}

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

/* ============ Focus visible ============ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus:not(:focus-visible),
select:focus:not(:focus-visible),
input:focus:not(:focus-visible) { outline: none; }

/* High contrast support */
@media (prefers-contrast: more) {
  :root { --border: #555; --border-soft: #444; --text-3: #ccc; }
}
