/* ===========================
   Tema Biru Modern + Glassmorphism (All-Device Ready)
   - Responsif: mobile 320px → ultra-wide
   - Fluid typography (clamp)
   - Safe area (iOS notch), coarse pointer tweaks
   - Aksesibilitas: :focus-visible, prefers-reduced-motion, high contrast
   =========================== */

:root{
  --bg: #0b1224;
  --bg2:#0e1b3d;
  --glass: rgba(255,255,255,0.08);
  --glass-2: rgba(255,255,255,0.12);
  --stroke: rgba(255,255,255,0.15);
  --text: #eaf2ff;
  --muted: #a9b7d9;
  --blue: #3b82f6;
  --blue-strong: #2563eb;
  --focus: #93c5fd;
  --shadow: 0 20px 40px rgba(0,0,0,0.35);

  /* Fluid type scale */
  --fs-base: clamp(14px, 1.2vw + 10px, 16px);
  --fs-sm: clamp(12px, 0.9vw + 9px, 14px);
  --fs-lg: clamp(16px, 1.4vw + 10px, 18px);
  --fs-xl: clamp(20px, 2.2vw + 10px, 30px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji';
  font-size: var(--fs-base);
  line-height: 1.45;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%) fixed;
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
  text-wrap: pretty;
}

/* =========================== Layout & Hero =========================== */
.page{
  width: min(1100px, 96vw);
  margin: 40px auto;
  padding: 0 16px;
}
.hero{ text-align: center; margin-bottom: 22px; }
.logo{ font-size: 36px; }
.hero h1{
  margin: 8px 0 6px;
  font-weight: 800;
  letter-spacing: .2px;
  font-size: var(--fs-xl);
  text-wrap: balance;
}
.hero h1 span{ color: var(--focus); }
.tagline{ color: var(--muted); margin: 0; font-size: var(--fs-sm); }

/* =========================== Card / Glass Panel =========================== */
.card{
  background:
    radial-gradient(1100px 700px at 10% -10%, rgba(59,130,246,0.12), transparent),
    radial-gradient(900px 600px at 100% 10%, rgba(37,99,235,0.12), transparent),
    var(--glass);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: clamp(14px, 2vw, 18px);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* =========================== Segmented Control =========================== */
.segmented{
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--stroke);
  border-radius: 14px; padding: 4px; margin-bottom: 16px; isolation: isolate;
}
.segmented input{ display: none; }
.segmented label{
  cursor: pointer; text-align: center; padding: 10px 12px; border-radius: 10px;
  font-weight: 700; color: var(--text); transition: color .2s ease; position: relative; z-index: 2;
  min-height: 44px; display: grid; place-items: center;  /* touch friendly */
}
.segmented .segmented-bg{
  position: absolute; top: 4px; bottom: 4px; width: calc(50% - 4px); left: 4px;
  background: linear-gradient(180deg, rgba(59,130,246,0.9), rgba(37,99,235,0.9));
  border-radius: 10px; transition: transform .25s ease; z-index: 1;
  box-shadow: 0 10px 24px rgba(0,0,0,0.3);
}
#en-id:checked ~ .segmented-bg { transform: translateX(100%); }
#id-en:checked ~ label[for="id-en"],
#en-id:checked ~ label[for="en-id"] { color: white; }

/* =========================== Grid & Panels =========================== */
.grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(10px, 2vw, 14px);
}
.panel{
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 12px;
  min-height: 260px;
  position: relative;
}
.panel-head{
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;
  gap: 8px;
}
.lang-badge{
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 28px; border-radius: 8px;
  background: linear-gradient(180deg, var(--blue), var(--blue-strong));
  color: #fff; font-weight: 800; letter-spacing: .6px; border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 6px 14px rgba(0,0,0,0.25);
  font-size: var(--fs-sm);
}

/* =========================== Inputs =========================== */
.panel textarea{
  width: 100%; min-height: 210px; resize: vertical; background: transparent;
  border: none; outline: none; font: inherit; color: var(--text); line-height: 1.5;
}
.panel textarea::placeholder{ color: #a7b3d0; }
.bar{ display: flex; align-items: center; justify-content: space-between; margin-top: 6px; gap: 8px; }
.hint{ color: var(--muted); font-size: var(--fs-sm); }
.counter{ font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; }

/* =========================== Output =========================== */
.output{ display: flex; flex-direction: column; }
.output-toolbar{ display: flex; gap: 8px; flex-wrap: wrap; }
.output-box{
  flex: 1; border: 1px dashed var(--stroke); border-radius: 10px; padding: 12px; min-height: 180px;
  background: rgba(255,255,255,0.03); overflow-wrap: anywhere; font-size: var(--fs-base);
}

/* =========================== Buttons =========================== */
.btn{
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid var(--stroke); background: rgba(255,255,255,0.06); color: var(--text);
  padding: 10px 14px; font-weight: 800; border-radius: 12px; cursor: pointer;
  transition: transform .06s ease, background .2s ease, box-shadow .2s ease;
  box-shadow: 0 8px 18px rgba(0,0,0,0.22);
  min-height: 44px; /* touch target */
}
.btn:active{ transform: translateY(1px); }
@media (hover:hover){
  .btn:hover{ background: rgba(255,255,255,0.1); }
}
.btn:focus-visible{ outline: 3px solid var(--focus); outline-offset: 3px; }
.btn-primary{
  background: linear-gradient(180deg, var(--blue), var(--blue-strong));
  border-color: rgba(255,255,255,0.18);
}
.btn-secondary{ background: rgba(255,255,255,0.08); }
.btn-ghost{ background: transparent; }
.btn.sm{ padding: 6px 10px; font-weight: 700; border-radius: 10px; min-height: 36px; }

/* =========================== Spinner =========================== */
.spinner{
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.55); border-top-color: transparent;
  display: none; animation: spin .8s linear infinite;
}
.btn.loading .spinner{ display: inline-block; }
.btn.loading .btn-label{ opacity: .75; }
@keyframes spin{ to{ transform: rotate(360deg); } }

/* =========================== Actions =========================== */
.actions{ display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* =========================== Toast =========================== */
.toast{
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: rgba(15,23,42,0.94); color: #e6f0ff; border: 1px solid var(--stroke);
  border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow);
  display: none; z-index: 1000; max-width: 90vw;
}
.toast.show{ display: inline-block; }
.toast.error{ background: rgba(127,29,29,0.94); }

/* =========================== Footer =========================== */
.foot{ text-align: center; color: var(--muted); margin-top: 18px; font-size: var(--fs-sm); }

/* =========================== A11y Helpers =========================== */
.sr-only{
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* =========================== Responsive Breakpoints =========================== */
/* Tablet portrait dan kebawah */
@media (max-width: 900px){
  .grid{ grid-template-columns: 1fr; }
  .page{ margin: 24px auto; }
}

/* Ponsel ≤600px */
@media (max-width: 600px){
  .card{ padding: 12px; border-radius: 16px; }
  .panel{ padding: 10px; border-radius: 12px; }
  .logo{ font-size: 30px; }
  .output-box{ min-height: 160px; }
  .actions{ gap: 8px; }
}

/* Ponsel kecil ≤400px (320–400px aman) */
@media (max-width: 400px){
  .page{ width: min(100%, 96vw); padding: 0 10px; }
  .btn{ padding: 10px 12px; }
  .segmented label{ padding: 10px 8px; }
}

/* Layar lebar ≥1400px: sedikit longgar */
@media (min-width: 1400px){
  .page{ width: min(1200px, 88vw); }
  .card{ padding: 22px; }
}

/* Orientasi landscape di perangkat kecil: pertahankan 2 kolom jika muat */
@media (orientation: landscape) and (max-height: 500px) and (min-width: 700px){
  .grid{ grid-template-columns: 1fr 1fr; }
}

/* =========================== Motion & Contrast Preferences =========================== */
@media (prefers-reduced-motion: reduce){
  * { animation: none !important; transition: none !important; }
  .spinner{ display: none !important; }
}

@media (prefers-contrast: more){
  :root{
    --stroke: rgba(255,255,255,0.35);
  }
  .card, .panel, .segmented{ border-width: 2px; }
}

/* High Contrast Mode (Windows) */
@media (forced-colors: active){
  .card, .panel, .segmented, .btn, .output-box{ border: 1px solid CanvasText; }
  .btn:focus-visible{ outline: 2px solid Highlight; }
}

/* =========================== Pointer/Touch Tweaks =========================== */
@media (pointer: coarse){
  .btn, .segmented label{ min-height: 48px; }
  .panel textarea{ min-height: 180px; }
}

/* =========================== Print (jika perlu cetak hasil) =========================== */
@media print{
  body{ background: #fff; color: #111; }
  .card, .panel, .segmented, .btn, .toast{ box-shadow: none; backdrop-filter: none; }
  .actions, .segmented, .toast{ display: none !important; }
  .output-box{ border: 1px solid #bbb; }
}
