:root{
  --paper:#fbfbfb;
  --ink:#121212;
  --muted:#666;
  --hair:#e1e1e1;
  --focus:#b9b9b9;

  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background:var(--paper);
  color:var(--ink);
  font-family:var(--mono);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

.app{
  height:100%;
  display:flex;
  overflow:hidden;
}

/* Sidebar */
.sidebar{
  width: 280px;
  border-right:1px solid var(--hair);
  display:flex;
  flex-direction:column;
  background:var(--paper);
}
.sidebar__header{
  padding:14px 14px 10px 14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.brand{
  font-size:14px;
  letter-spacing:0.5px;
}
.sidebar__tools{
  padding:0 14px 10px 14px;
}
.search{
  width:100%;
  border:1px solid var(--hair);
  border-radius:10px;
  padding:10px 10px;
  background:transparent;
  font-family:var(--mono);
  font-size:12px;
  outline:none;
}
.search:focus{ border-color:var(--focus); }

.list{
  flex:1;
  overflow:auto;
  padding:4px 6px 8px 6px;
}
.item{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding:10px 10px;
  margin:4px 6px;
  border-radius:10px;
  cursor:pointer;
  user-select:none;
}
.item:hover{ background:rgba(0,0,0,0.04); }
.item[aria-current="true"]{ background:rgba(0,0,0,0.06); }
.item__left{ display:flex; flex-direction:column; gap:3px; min-width:0; }
.item__date{ font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.item__meta{ font-size:11px; color:var(--muted); }
.item__right{ color:var(--muted); font-size:12px; }

.sidebar__footer{
  padding:10px 14px 14px 14px;
  border-top:1px solid var(--hair);
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

/* Main */
.main{
  position:relative;
  flex:1;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.topbar{
  position:sticky;
  top:0;
  z-index:20;
  background:var(--paper);
  height:44px;
  border-bottom:1px solid var(--hair);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 12px;
  gap:10px;
}
.topbar__left{ display:flex; align-items:center; gap:10px; }
.status{ font-size:12px; color:var(--muted); }
.topbar__right{ display:flex; align-items:center; gap:10px; }

.page{
  flex:1;
  overflow:auto;
  padding:26px 22px 60px 22px;
  max-width: 920px;
  width:100%;
  margin:0 auto;
}

.page__header{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:16px;
  margin-bottom:16px;
}
.date{
  margin:0;
  font-size:18px;
  font-weight:600;
}
.hint{
  font-size:11px;
  color:var(--muted);
  text-align:right;
  line-height:1.3;
}

.block{
  margin-top:18px;
}
.block h2{
  margin:0 0 8px 0;
  font-size:13px;
  font-weight:600;
}
textarea{
  width:100%;
  min-height:170px;
  resize:vertical;
  padding:12px 12px;
  border:1px solid var(--hair);
  border-radius:12px;
  background:transparent;
  color:var(--ink);
  font-family:var(--mono);
  font-size:14px;
  line-height:1.55;
  outline:none;
}
textarea:focus{ border-color:var(--focus); }
textarea.commitment{ min-height:90px; }

.page__footer{
  margin-top:22px;
  padding-top:16px;
  border-top:1px solid var(--hair);
}
.footline{
  font-size:11px;
  color:var(--muted);
}

/* Buttons */
.btn{
  border:1px solid var(--hair);
  background:transparent;
  border-radius:10px;
  padding:8px 10px;
  font-family:var(--mono);
  font-size:12px;
  cursor:pointer;
}
.btn:hover{ background:rgba(0,0,0,0.04); }
.btn:active{ background:rgba(0,0,0,0.06); }
.btn--ghost{
  border-color:transparent;
}
.btn--primary{
  border-color:transparent;
  background:rgba(0,0,0,0.08);
}
.btn--primary:hover{ background:rgba(0,0,0,0.10); }
.filebtn input{ display:none; }

/* Auth overlay */
.auth{
  position:fixed;
  z-index:9999;
  inset:0;
  background:var(--paper);
  display:none;
  align-items:center;
  justify-content:center;
  padding:22px;
}
.auth.show{ display:flex; }
.auth__card{
  width:min(420px, 100%);
  border:1px solid var(--hair);
  border-radius:16px;
  padding:18px 18px 16px 18px;
}
.auth__title{
  font-size:16px;
  font-weight:700;
  letter-spacing:0.4px;
  margin-bottom:6px;
}
.auth__sub{
  font-size:12px;
  color:var(--muted);
  margin-bottom:14px;
}
.auth__label{ font-size:12px; color:var(--muted); display:block; margin-bottom:6px; }
.auth__input{
  width:100%;
  border:1px solid var(--hair);
  border-radius:12px;
  padding:12px 12px;
  background:transparent;
  font-family:var(--mono);
  font-size:13px;
  outline:none;
  margin-bottom:10px;
}
.auth__input:focus{ border-color:var(--focus); }
.auth__hint{ font-size:11px; color:var(--muted); margin-top:10px; line-height:1.35; }
.auth__error{ font-size:11px; color:#b00020; margin-top:8px; white-space:pre-wrap; }

/* Mobile */
@media (max-width: 820px){
  .sidebar{ width: 240px; }
  .page{ padding:18px 14px 46px 14px; }
  textarea{ min-height:160px; }
}

@media (max-width: 640px){
  .app{ flex-direction:column; }
  .sidebar{
    width:100%;
    height: 220px;
    border-right:none;
    border-bottom:1px solid var(--hair);
  }
  .page__header{
    flex-direction:column;
    align-items:flex-start;
  }
  .hint{ text-align:left; }
}

/* Sidebar hidden state */
body.sidebar-hidden .sidebar{ display:none; }


/* When auth gate is open, lock the underlying UI */
body.auth-open{ overflow:hidden; }


/* Modal */
.modal{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  padding:24px;
  z-index:10000;
}
.modal.show{ display:flex; }

.modal__backdrop{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,0.25);
}

.modal__card{
  position:relative;
  width:min(720px, 92vw);
  background:var(--paper);
  border:1px solid var(--hairline);
  border-radius:12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  padding:18px 18px 16px;
}

.modal__head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding-bottom:10px;
  border-bottom:1px solid var(--hairline);
  margin-bottom:12px;
}

.modal__title{
  font-weight:600;
  letter-spacing:0.2px;
}

.modal__body{
  font-size:13px;
  line-height:1.55;
  color:var(--ink);
}
.modal__body p{ margin: 0 0 10px; }
.modal__body p:last-child{ margin-bottom:0; }


/* Auth (login) about blurb */
.auth__about{
  margin: 10px 0 14px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}
.auth__about .auth__more{
  margin-left: 6px;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.auth__about .auth__more:hover{ opacity: 0.75; }
