:root{
  --bg0:#faf7ff;
  --bg1:#f3fbff;
  --card:#ffffffcc;
  --cardSolid:#fff;
  --text:#1f2430;
  --muted:#667085;
  --border:#e6e8f0;
  --shadow: 0 18px 50px rgba(20, 18, 40, .12);
  --shadowSoft: 0 12px 30px rgba(20, 18, 40, .10);
  --accent:#7c5cff; /* lavender */
  --accent2:#37c6ff; /* sky */
  --good:#10b981;
  --danger:#ef4444;
  --radius:18px;
  --radiusSm:12px;
  --ring: 0 0 0 4px rgba(124, 92, 255, .18);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: var(--sans);
  color:var(--text);
  background:
    radial-gradient(900px 500px at 15% 0%, rgba(124, 92, 255, .18), transparent 60%),
    radial-gradient(900px 500px at 85% 10%, rgba(55, 198, 255, .16), transparent 55%),
    radial-gradient(700px 500px at 40% 90%, rgba(255, 171, 236, .14), transparent 60%),
    linear-gradient(135deg, var(--bg0), var(--bg1));
  padding: 28px;
}

.app{
  max-width: 1120px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid rgba(230, 232, 240, .9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
}

.header{
  display:flex;
  gap:22px;
  align-items:stretch;
  justify-content:space-between;
  padding: 22px 22px 18px;
  border-bottom: 1px solid rgba(230, 232, 240, .8);
  background: linear-gradient(180deg, rgba(255,255,255,.82), rgba(255,255,255,.55));
}

.brand{
  display:flex;
  align-items:center;
  gap:14px;
  min-width: 260px;
}

.brand__logo{
  width: 44px;
  height: 44px;
  border-radius: 14px;
  padding: 8px;
  background: #fff;
  border: 1px solid rgba(230, 232, 240, .9);
  box-shadow: var(--shadowSoft);
}

.brand__text h1{
  margin:0;
  font-size: 1.35rem;
  letter-spacing: .2px;
}

.subtitle{
  margin: 2px 0 0;
  color: var(--muted);
  font-size: .93rem;
}

.controls{
  display:flex;
  flex-direction:column;
  gap: 12px;
  justify-content:center;
  min-width: 340px;
}

.field{
  display:flex;
  flex-direction:column;
  gap: 6px;
}

.field__label{
  font-size: .86rem;
  color: var(--muted);
}

.select{
  width:100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.92);
  color: var(--text);
  font-size: .98rem;
  outline:none;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.select:focus{
  border-color: rgba(124, 92, 255, .55);
  box-shadow: var(--ring);
}

.toggles{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
}

.toggle{
  display:flex;
  gap: 10px;
  align-items:center;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(230, 232, 240, .9);
  background: rgba(255,255,255,.7);
}

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

.toggle__ui{
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: rgba(102, 112, 133, .22);
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(230, 232, 240, .9);
  transition: background .18s ease;
}

.toggle__ui::after{
  content:"";
  position:absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 6px 14px rgba(20, 18, 40, .18);
  transition: transform .18s ease;
}

.toggle input:checked + .toggle__ui{
  background: linear-gradient(90deg, rgba(124,92,255,.85), rgba(55,198,255,.75));
}
.toggle input:checked + .toggle__ui::after{
  transform: translateX(18px);
}

.toggle__label{
  font-size: .92rem;
  color: var(--text);
}

.workspace{
  display:grid;
  grid-template-columns: 1.3fr .7fr;
  gap: 18px;
  padding: 18px;
}

.editor-wrap{
  display:flex;
  flex-direction:column;
  gap: 10px;
}

.toolbar{
  display:flex;
  gap: 10px;
  align-items:center;
  flex-wrap: wrap;
}

.btn{
  display:inline-flex;
  align-items:center;
  gap: 10px;
  border: none;
  border-radius: 14px;
  padding: 10px 14px;
  background: linear-gradient(90deg, rgba(124,92,255,.95), rgba(55,198,255,.9));
  color: #fff;
  font-weight: 700;
  cursor:pointer;
  box-shadow: 0 10px 22px rgba(124,92,255,.23);
  transition: transform .08s ease, filter .15s ease;
}
.btn:hover{ filter: brightness(1.02); }
.btn:active{ transform: translateY(1px); }
.btn:focus-visible{ outline:none; box-shadow: var(--ring), 0 10px 22px rgba(124,92,255,.23); }

.btn__icon{ width: 18px; height: 18px; filter: drop-shadow(0 4px 8px rgba(0,0,0,.18)); }

.btn--ghost{
  background: rgba(255,255,255,.65);
  color: var(--text);
  border: 1px solid rgba(230, 232, 240, .95);
  box-shadow: none;
  font-weight: 700;
}

.hint{
  margin-left:auto;
  color: var(--muted);
  font-size: .92rem;
  display:flex;
  gap: 6px;
  align-items:center;
  flex-wrap: wrap;
}

.kbd{
  font-family: var(--mono);
  font-size: .85rem;
  padding: 2px 7px;
  border-radius: 9px;
  border: 1px solid rgba(230, 232, 240, .95);
  background: rgba(255,255,255,.8);
  box-shadow: 0 6px 14px rgba(20, 18, 40, .08);
}

.editor-shell{
  position: relative;
  border-radius: var(--radius);
  border: 1px solid rgba(230, 232, 240, .95);
  background: rgba(255,255,255,.85);
  box-shadow: var(--shadowSoft);
  min-height: 280px;
  padding: 14px 14px 18px;
  overflow: hidden;
}

.editor-shell:focus-within{
  border-color: rgba(124, 92, 255, .55);
  box-shadow: var(--ring), var(--shadowSoft);
}

.editor{
  min-height: 240px;
  outline: none;
  font-size: 1.06rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.preedit{
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  text-decoration-color: rgba(124, 92, 255, .9);
  padding: 0 2px;
  border-radius: 6px;
  background: rgba(124, 92, 255, .08);
}

.preedit__raw{
  font-family: var(--mono);
  font-size: .95em;
  color: rgba(102,112,133,.95);
  margin-left: 2px;
}

.preview{
  margin: 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.65);
  border: 1px solid rgba(230, 232, 240, .9);
  color: var(--muted);
  min-height: 40px;
}

.side{
  display:flex;
  flex-direction:column;
  gap: 12px;
}

.card{
  border-radius: var(--radius);
  background: rgba(255,255,255,.74);
  border: 1px solid rgba(230, 232, 240, .9);
  box-shadow: 0 10px 22px rgba(20, 18, 40, .07);
  padding: 14px 14px 12px;
}

.card--soft{
  background: rgba(255,255,255,.55);
}

.card h2{
  margin: 0 0 8px;
  font-size: 1rem;
}

.card p, .card li{
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.55;
}

.card ul{ padding-left: 18px; margin: 0; }

.cand{
  position: absolute;
  max-width: min(560px, calc(100% - 24px));
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(230, 232, 240, .95);
  box-shadow: 0 16px 42px rgba(20, 18, 40, .16);
  border-radius: 16px;
  padding: 10px;
  z-index: 20;
  transform-origin: top left;
  animation: pop .12s ease-out;
}

@keyframes pop{
  from{ transform: translateY(-4px) scale(.98); opacity: .0; }
  to{ transform: translateY(0) scale(1); opacity: 1; }
}

.hidden{ display:none; }

.cand__raw{
  font-family: var(--mono);
  font-size: .86rem;
  color: var(--muted);
  padding: 0 6px 8px;
}

.cand__list{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 4px 2px;
}

.cand__item{
  display:flex;
  gap: 8px;
  align-items:center;
  border-radius: 14px;
  border: 1px solid rgba(230, 232, 240, .95);
  background: rgba(255,255,255,.85);
  padding: 8px 10px;
  cursor:pointer;
  user-select:none;
  transition: transform .06s ease, border-color .12s ease, background .12s ease;
}

.cand__item:hover{ transform: translateY(-1px); }

.cand__item[aria-selected="true"]{
  border-color: rgba(124, 92, 255, .55);
  background: rgba(124, 92, 255, .10);
}

.cand__key{
  font-family: var(--mono);
  font-size: .82rem;
  color: rgba(31, 36, 48, .92);
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(124, 92, 255, .10);
  border: 1px solid rgba(124, 92, 255, .18);
}

.cand__text{ font-size: 1rem; }

.toast{
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(31, 36, 48, .92);
  color: #fff;
  box-shadow: 0 16px 42px rgba(0,0,0,.22);
  opacity: 0;
  pointer-events:none;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.show{
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

@media (max-width: 960px){
  .workspace{ grid-template-columns: 1fr; }
  .controls{ min-width: unset; }
  .brand{ min-width: unset; }
}

@media (prefers-reduced-motion: reduce){
  *{ transition:none !important; animation:none !important; }
}
