:root{
  --bg0:#eaf1ff;
  --bg1:#f3f7ff;
  --card:#ffffff;
  --card-highlight:#fbfdff;
  --text:#1e293b;
  --muted:#475569;
  --muted2:#64748b;
  --stroke:#cbd5e1;
  --shadow: 0 14px 38px rgba(30,41,59,.12);
  --radius: 18px;
  --blue:#3b82f6;
  --blue-ink:#1d4ed8;
  --focus: 0 0 0 4px rgba(59,130,246,.25);
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}

*{ box-sizing:border-box; }
html, body{ height:100%; }

body{
  margin:0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(800px 480px at 15% 12%, #dbe7ff, transparent 60%),
    radial-gradient(800px 480px at 85% 15%, #e3f6ea, transparent 60%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

.container{
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px 16px 34px;
}

/* ===== Header (identical behavior everywhere) ===== */

.topbar{
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(243,247,255,.78);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(203,213,225,.7);
}
.topbar-inner{
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 12px 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
}

.brand{
  display:flex;
  align-items:center;
  gap: 10px;
  min-width:0;
}
.loogo{
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: linear-gradient(135deg, #60a5fa, #93c5fd);
  display:grid;
  place-items:center;
  box-shadow: 0 6px 16px rgba(59,130,246,.28);
  flex: 0 0 auto;
}
.logo{
  background: transparent; /* remove blue gradient */
  box-shadow: none;        /* optional: remove glow */
}

.logo-img{
  width: 40px;
  height: 40px;
  object-fit: contain;
  display: block;
}

.logo svg{ width: 22px; height: 22px; }
.brand-name{
  display:flex;
  flex-direction:column;
  min-width:0;
}
.brand-name strong{
  font-size: 14px;
  letter-spacing:.2px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.brand-name span{
  font-size: 12px;
  color: var(--muted2);
}

.nav{
  display:flex;
  align-items:center;
  gap: 10px;
}
.nav a{
  text-decoration:none;
  color: var(--muted);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
}
.nav a:hover{
  color: var(--text);
  border-color: rgba(203,213,225,.8);
  background: rgba(255,255,255,.55);
}
.nav a.active{
  color: var(--blue-ink);
  background: rgba(59,130,246,.10);
  border-color: rgba(59,130,246,.18);
  font-weight: 650;
}

.hamburger{
  display:none;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid rgba(203,213,225,.85);
  background: rgba(255,255,255,.65);
  box-shadow: 0 6px 14px rgba(30,41,59,.07);
  cursor:pointer;
}
.hamburger:focus{ outline:none; box-shadow: var(--focus); }
.hamburger svg{ width: 20px; height: 20px; }

.profile-chip{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(203,213,225,.85);
  background: rgba(255,255,255,.65);
  box-shadow: 0 6px 14px rgba(30,41,59,.07);
}
.avatar{
  width: 30px; height: 30px;
  border-radius: 999px;
  background: linear-gradient(135deg, #93c5fd, #bfdbfe);
  border: 1px solid rgba(59,130,246,.22);
  display:grid;
  place-items:center;
  font-weight: 800;
  color: rgba(30,41,59,.85);
  font-size: 12px;
  letter-spacing:.3px;
}
.profile-chip span{
  font-size: 13px;
  color: var(--muted);
  white-space:nowrap;
  max-width: 180px;
  overflow:hidden;
  text-overflow:ellipsis;
}

@media (max-width: 860px){
  .nav{ display:none; }
  .hamburger{ display:grid; place-items:center; }
  .profile-chip span{ display:none; }
}

.drawer{
  display:none;
  border-top: 1px solid rgba(203,213,225,.7);
  background: rgba(243,247,255,.92);
  backdrop-filter: blur(10px);
}
.drawer.open{ display:block; }
.drawer a{
  display:block;
  padding: 12px 16px;
  text-decoration:none;
  color: var(--muted);
  border-bottom: 1px solid rgba(203,213,225,.55);
  font-size: 14px;
}
.drawer a:hover{ background: rgba(255,255,255,.55); color: var(--text); }
.drawer a.active{ color: var(--blue-ink); font-weight: 700; background: rgba(59,130,246,.10); }

/* ===== Common components ===== */

.section{
  margin-top: 18px;
  background: linear-gradient(180deg, var(--card-highlight), var(--card));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(203,213,225,.9);
  background: #ffffff;
  color: var(--text);
  text-decoration:none;
  font-weight: 650;
  font-size: 13px;
  box-shadow: 0 4px 10px rgba(30,41,59,.07);
  transition: transform .06s ease, background .12s ease;
  cursor: pointer;
}
.btn:hover{ background:#f8fbff; transform: translateY(-1px); }
.btn:focus{ outline:none; box-shadow: var(--focus); }
.btn.primary{
  background: rgba(59,130,246,.12);
  border-color: rgba(59,130,246,.22);
  color: var(--blue-ink);
}
.btn.primary:hover{ background: rgba(59,130,246,.16); }

/* ===== Forms (used by profile.php and future create-chain pages) ===== */

h1{ margin: 0 0 6px; font-size: 22px; letter-spacing:.2px; }
p{ margin: 10px 0; color: var(--muted); line-height: 1.6; }

label{
  display:block;
  font-size: 13px;
  color: var(--muted2);
  margin: 10px 0 6px;
}

input, textarea, select{
  width: 100%;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(203,213,225,.9);
  font-size: 14px;
  outline: none;
  background: #fff;
  color: var(--text);
}

textarea{
  min-height: 120px;
  resize: vertical;
}

input:focus, textarea:focus, select:focus{
  box-shadow: var(--focus);
  border-color: rgba(59,130,246,.35);
}

.row{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 860px){
  .row{ grid-template-columns: 1fr; }
}

.msg{
  margin-top: 12px;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
}

.msg.ok{
  border: 1px solid rgba(34,197,94,.25);
  background: rgba(34,197,94,.08);
  color: #166534;
}

.msg.err{
  border: 1px solid rgba(239,68,68,.25);
  background: rgba(239,68,68,.08);
  color: #7f1d1d;
}

.note{
  border: 1px dashed #a5b4fc;
  background: #f8fbff;
  border-radius: 14px;
  padding: 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  margin-top: 14px;
}

/* ===== Login Page (index.php) ===== */

.wrap{
  min-height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 28px 16px;
}

.shell{
  width: min(1080px, 100%);
  display:grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 26px;
}

@media (max-width: 900px){
  .shell{ grid-template-columns: 1fr; }
}

.panel{
  background:
    linear-gradient(180deg, var(--card-highlight), var(--card));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
}

header.top{
  display:flex;
  align-items:center;
  gap: 12px;
  margin-bottom: 14px;
}

.logo{
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, #60a5fa, #93c5fd);
  display:grid;
  place-items:center;
  box-shadow: 0 6px 16px rgba(59,130,246,.35);
}

.logo svg{ width: 26px; height: 26px; }

.brand h1{
  font-size: 16px;
  margin: 0;
  letter-spacing: .3px;
}

.brand .tag{
  font-size: 12px;
  color: var(--muted2);
}

.hero h2{
  margin: 10px 0 8px;
  font-size: clamp(22px, 2.6vw, 34px);
  line-height: 1.15;
}

.hero p{
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
  max-width: 60ch;
}

.points{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

@media (max-width: 520px){
  .points{ grid-template-columns: 1fr; }
}

.point{
  border: 1px solid var(--stroke);
  background: #ffffff;
  border-radius: 14px;
  padding: 14px;
}

.point strong{
  display:block;
  font-size: 13px;
  margin-bottom: 4px;
}

.point span{
  font-size: 13px;
  color: var(--muted2);
  line-height: 1.45;
}

.side h3{
  margin: 6px 0 8px;
  font-size: 16px;
}

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

.btns{
  display:flex;
  flex-direction:column;
  gap: 14px;
  margin: 14px 0;
}

.panel .btn{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: #ffffff;
  color: var(--text);
  text-decoration:none;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(30,41,59,.08);
  transition: background .12s ease, transform .06s ease;
}

.panel .btn:hover{
  background: #f8fbff;
  transform: translateY(-1px);
}

.panel .btn:focus{ outline:none; box-shadow: var(--focus); }

.panel .btn svg{
  width: 18px;
  height: 18px;
}

.divider{
  display:flex;
  align-items:center;
  gap: 10px;
  margin: 16px 0;
  color: var(--muted2);
  font-size: 12px;
}

.divider::before, .divider::after{
  content:"";
  height:1px;
  flex:1;
  background: var(--stroke);
}

.public-note{
  border: 1px dashed #a5b4fc;
  background: #f8fbff;
  border-radius: 14px;
  padding: 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.fineprint{
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted2);
  line-height: 1.5;
}

.links{
  margin-top: 12px;
  display:flex;
  gap: 14px;
  font-size: 12px;
}

.links a{
  color: var(--blue);
  text-decoration:none;
}

.links a:hover{ text-decoration:underline; }

footer{
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted2);
  display:flex;
  justify-content:space-between;
  gap: 10px;
  flex-wrap:wrap;
}

/* ===== Auth Error Page (auth-error.php) ===== */

.error-shell{
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
  margin: auto;
  min-height: 100vh;
  place-items: center;
  padding: 24px 16px;
}

@media (max-width: 900px){
  .error-shell{ grid-template-columns: 1fr; }
}

/* ===== Create Chain Page (create_chain.php) ===== */

.page-head{
  margin-top: 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.page-head h1{ 
  margin: 0; 
  font-size: 22px; 
  letter-spacing: 0.2px; 
}

.page-head p{ 
  margin: 6px 0 0; 
  color: var(--muted); 
  font-size: 14px; 
  line-height: 1.5; 
  max-width: 72ch; 
}

.pill{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(203,213,225,.9);
  background: rgba(255,255,255,.75);
  font-size: 13px;
  color: var(--muted);
}

.hint{
  font-size: 12px;
  color: var(--muted2);
  margin-top: 8px;
  line-height: 1.45;
}

.toggle{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(203,213,225,.9);
  background: rgba(248,251,255,.65);
}

.toggle input{ width: auto; }
.toggle b{ font-size: 13px; }

.radio-row{
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.radio{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(203,213,225,.9);
  background: rgba(248,251,255,.65);
  font-size: 13px;
  color: var(--muted);
}

.radio input{ width: auto; }

.split{
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
}

@media (max-width: 980px){ 
  .split{ grid-template-columns: 1fr; } 
}

.preview{
  border: 1px dashed #a5b4fc;
  background: #f8fbff;
  border-radius: 14px;
  padding: 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}

.preview b{ color: var(--text); }

.btnrow{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
