:root{color-scheme:dark;}
*{box-sizing:border-box;}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background: radial-gradient(1200px 600px at 50% 20%, rgba(80,120,255,.18), transparent 60%),
              radial-gradient(900px 500px at 60% 60%, rgba(0,200,255,.10), transparent 60%),
              #0b0f17;
  color:#e7eefc;
  min-height:100vh;
}
a{color:#9cc2ff; text-decoration:none;}
a:hover{text-decoration:underline;}
.container{max-width:1200px;margin:0 auto;padding:28px 18px;}
.card{
  background: rgba(18,24,38,.72);
  border:1px solid rgba(255,255,255,.08);
  border-radius:18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  backdrop-filter: blur(10px);
}
header.site{
  display:flex; align-items:center; justify-content:space-between;
  gap:14px; padding:16px 18px;
  flex-wrap: wrap;
}
.brand{display:flex; align-items:center; gap:10px;}
.logo{
  width:34px;height:34px;border-radius:10px;
  background: linear-gradient(135deg, rgba(120,160,255,.9), rgba(0,220,255,.75));
  box-shadow: 0 10px 30px rgba(0,200,255,.15);
}
h1,h2,h3,h4{margin:0;}
h1{font-size:22px;}
h2{font-size:16px; margin-bottom:8px;}
h3{font-size:15px; color: rgba(231,238,252,.9);}
h4{font-size:13px; color: rgba(231,238,252,.7); margin-bottom:6px;}
small.muted{color:rgba(231,238,252,.65);}
.btn{
  display:inline-flex; align-items:center; justify-content:center;
  gap:8px;
  padding:10px 14px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color:#e7eefc;
  cursor:pointer;
  user-select:none;
  font-size: 14px;
}
.btn:hover{background: rgba(255,255,255,.10);}
.btn.primary{
  background: linear-gradient(135deg, rgba(120,160,255,.95), rgba(0,220,255,.75));
  border-color: rgba(255,255,255,.18);
  color:#061021;
  font-weight:700;
}
.btn.danger{
  background: rgba(255,70,90,.18);
  border-color: rgba(255,70,90,.35);
}
.btn.danger:hover{background: rgba(255,70,90,.25);}
.btn.small{
  padding: 6px 10px;
  font-size: 12px;
}
.toolbar{
  display:flex; flex-wrap:wrap; gap:10px; justify-content:flex-end; align-items:center;
}
.grid{
  display:grid;
  grid-template-columns: 1.1fr .9fr;
  gap:16px;
  padding:18px;
}
@media (max-width: 1000px){
  .grid{grid-template-columns:1fr;}
  .toolbar{justify-content:flex-start;}
}
.panel{
  padding:16px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(10,14,22,.55);
}
.row{display:flex; gap:10px; align-items:flex-end; flex-wrap:wrap; margin-bottom: 8px;}
.field{flex:1; min-width:180px;}
label{display:block; font-size:12px; color:rgba(231,238,252,.72); margin:0 0 6px;}
input[type="text"], input[type="email"], textarea, select{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.05);
  color:#e7eefc;
  outline:none;
  font-size: 14px;
}
input:focus, textarea:focus {
  border-color: rgba(120,160,255,.5);
  box-shadow: 0 0 0 2px rgba(120,160,255,.1);
}
input::placeholder, textarea::placeholder{color:rgba(231,238,252,.35);}
textarea{min-height:100px; resize:vertical; line-height:1.35;}
.pill{
  display:inline-flex; align-items:center; gap:8px;
  padding:6px 10px; border-radius:999px;
  background: rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.10);
  font-size:12px;
}
.kbd{font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;}
.hr{height:1px; background:rgba(255,255,255,.08); margin:14px 0;}
.note{color:rgba(231,238,252,.65); font-size:13px; line-height:1.35;}
.inline-actions{display:flex; gap:8px; align-items:center;}
.iconbtn{
  width:38px; height:38px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color:#e7eefc;
  cursor:pointer;
  flex-shrink: 0;
}
.iconbtn:hover{background: rgba(255,255,255,.10);}
.out{
  width:100%;
  padding:12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.25);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
  font-size:12px;
  white-space:pre-wrap;
  word-break:break-word;
  min-height:260px;
  max-height: 600px;
  overflow-y: auto;
}
footer{
  padding:14px 18px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  color:rgba(231,238,252,.55);
  font-size:12px;
}

/* AI Bar */
.ai-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(120,160,255,.12) 0%, rgba(0,220,255,.08) 100%);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.ai-bar input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.06);
  color: #e7eefc;
  font-size: 14px;
  outline: none;
}

.ai-bar input::placeholder {
  color: rgba(231,238,252,.45);
}

.ai-bar input:focus {
  border-color: rgba(120,160,255,.5);
  box-shadow: 0 0 0 3px rgba(120,160,255,.15);
}

.ai-bar .btn {
  white-space: nowrap;
  padding: 12px 18px;
}

.ai-bar .btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-header h2 {
  margin: 0;
}

/* Character Blocks */
.character-block {
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.character-block:last-child {
  margin-bottom: 0;
}

.character-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.character-header h3 {
  color: rgba(120,180,255,.95);
}

/* Subsections within character */
.subsection {
  background: rgba(0,0,0,.15);
  border-radius: 10px;
  padding: 12px;
  margin-top: 12px;
}

.subsection h4 {
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,.05);
}

.subsection .row {
  margin-bottom: 6px;
}

.subsection .row:last-child {
  margin-bottom: 0;
}

.subsection .field {
  min-width: 150px;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .field {
    min-width: 100%;
  }
  
  .subsection .field {
    min-width: 100%;
  }
  
  .character-header {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
  
  .section-header {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
  
  .ai-bar {
    flex-direction: column;
  }
  
  .ai-bar .btn {
    width: 100%;
  }
}

/* Scrollbar styling */
.out::-webkit-scrollbar {
  width: 8px;
}

.out::-webkit-scrollbar-track {
  background: rgba(0,0,0,.2);
  border-radius: 4px;
}

.out::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.15);
  border-radius: 4px;
}

.out::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,.25);
}
