@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Newsreader:opsz,wght@6..72,600&display=swap');

:root {
  --paper: #f4f6f2;
  --surface: #ffffff;
  --ink: #17211c;
  --muted: #68736c;
  --line: #dce2dc;
  --green: #176b4a;
  --green-soft: #dcefe6;
  --coral: #e86146;
  --yellow: #f2c94c;
  --sidebar: #13261f;
  --shadow: 0 18px 55px rgba(23, 33, 28, 0.12);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(23, 107, 74, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 107, 74, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  font-family: "DM Sans", sans-serif;
  letter-spacing: 0;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.mobile-only, .mobile-header { display: none; }

.login-shell {
  width: min(1040px, calc(100% - 40px));
  min-height: 610px;
  margin: clamp(24px, 7vh, 80px) auto;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.brand-panel {
  position: relative;
  overflow: hidden;
  padding: clamp(42px, 7vw, 88px);
  color: #f8faf8;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-panel::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  right: -120px;
  bottom: -110px;
  border: 42px solid var(--coral);
  transform: rotate(18deg);
  opacity: 0.62;
}

.brand-panel > * { position: relative; z-index: 1; }

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  background: var(--yellow);
  color: var(--sidebar);
  font-family: "Newsreader", serif;
  font-size: 30px;
  font-weight: 600;
}

.brand-mark.small { width: 34px; height: 34px; font-size: 21px; }
.eyebrow { margin: 24px 0 8px; color: var(--green); font-size: 11px; font-weight: 700; letter-spacing: 0.12em; }
.brand-panel .eyebrow { color: #99b9aa; }
.brand-panel h1 { margin: 0; font-family: "Newsreader", serif; font-size: clamp(74px, 10vw, 118px); line-height: 0.9; letter-spacing: 0; }
.brand-copy { max-width: 360px; margin: 28px 0; color: #bed0c7; font-size: 18px; line-height: 1.6; }
.brand-lines { display: flex; gap: 7px; margin-top: 28px; }
.brand-lines span { width: 54px; height: 5px; background: var(--coral); }
.brand-lines span:nth-child(2) { width: 28px; background: var(--yellow); }
.brand-lines span:nth-child(3) { width: 12px; background: #69a98c; }

.login-form {
  padding: clamp(42px, 7vw, 88px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
}

.login-form h2, .panel-heading h2 { margin: 0; font-family: "Newsreader", serif; font-size: 42px; }
.login-form label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.login-form input, .search-box input, .tag-row input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}
.login-form input { padding: 13px 0; border-bottom: 2px solid var(--line); font-size: 16px; }
.login-form input:focus { border-color: var(--green); }
.form-error { min-height: 20px; margin: -7px 0; color: #a52828; font-size: 13px; }

.primary-button, .save-button, .new-note-button, .voice-button {
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-weight: 700;
}
.primary-button { min-height: 50px; padding: 0 20px; color: white; background: var(--green); }
.primary-button svg, .save-button svg, .voice-button svg { width: 18px; }

.workspace-shell { height: 100dvh; display: grid; grid-template-columns: 230px minmax(290px, 390px) minmax(430px, 1fr); background: var(--surface); }
.sidebar { min-width: 0; padding: 24px 16px; color: white; background: var(--sidebar); display: flex; flex-direction: column; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; font-size: 17px; }
.new-note-button { min-height: 44px; margin: 36px 0 24px; color: var(--sidebar); background: var(--yellow); }
.new-note-button svg { width: 18px; }
.nav-list { display: grid; gap: 4px; }
.nav-item { min-height: 43px; padding: 0 12px; border: 0; color: #aec3b9; background: transparent; display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px; text-align: left; }
.nav-item svg { width: 17px; }
.nav-item b { font-size: 12px; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,0.1); }
.sidebar-footer { margin-top: auto; padding: 18px 4px 0; border-top: 1px solid rgba(255,255,255,0.12); display: flex; align-items: center; justify-content: space-between; color: #aec3b9; font-size: 12px; }
.sidebar-actions { display: flex; align-items: center; }

.icon-button { width: 38px; height: 38px; padding: 0; border: 0; display: grid; place-items: center; color: inherit; background: transparent; }
.icon-button svg { width: 19px; }
.icon-button:hover { background: rgba(128,128,128,0.12); }
.icon-button.danger { color: #b43a2d; }
.icon-button.accent { color: white; background: var(--green); }
.mobile-actions { display: flex; align-items: center; gap: 2px; }

.notes-panel { min-width: 0; padding: 30px 22px 0; border-right: 1px solid var(--line); background: #f8faf7; display: flex; flex-direction: column; overflow: hidden; }
.panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.panel-heading .eyebrow { margin-top: 0; }
.voice-button { min-height: 38px; padding: 0 13px; border: 1px solid var(--line); color: var(--green); background: white; }
.voice-button.recording { color: white; background: var(--coral); border-color: var(--coral); }
.search-box { min-height: 44px; margin: 24px 0 16px; padding: 0 13px; border: 1px solid var(--line); background: white; display: flex; align-items: center; gap: 9px; }
.search-box svg { width: 17px; color: var(--muted); }

.notes-list { margin: 0 -22px; padding: 0 12px 28px; overflow-y: auto; }
.note-card { width: 100%; min-height: 112px; padding: 17px 14px; border: 0; border-bottom: 1px solid var(--line); color: inherit; background: transparent; text-align: left; display: grid; gap: 8px; }
.note-card:hover { background: white; }
.note-card.active { background: white; box-shadow: inset 3px 0 var(--coral); }
.note-card h3 { margin: 0; overflow: hidden; font-family: "Newsreader", serif; font-size: 21px; white-space: nowrap; text-overflow: ellipsis; }
.note-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.note-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #87918b; font-size: 11px; }
.tag-list { display: flex; gap: 5px; min-width: 0; overflow: hidden; }
.tag-chip { padding: 3px 7px; color: var(--green); background: var(--green-soft); white-space: nowrap; }

.empty-state, .editor-placeholder { flex: 1; display: grid; place-content: center; justify-items: center; color: var(--muted); text-align: center; }
.empty-state svg, .editor-placeholder svg { width: 42px; height: 42px; color: #9eb0a7; }
.empty-state h3 { margin: 16px 0 4px; font-family: "Newsreader", serif; font-size: 25px; color: var(--ink); }
.empty-state p, .editor-placeholder p { margin: 0; font-size: 13px; }

.editor-panel { min-width: 0; background: white; overflow: hidden; }
.editor { height: 100%; display: flex; flex-direction: column; }
.editor-toolbar { min-height: 72px; padding: 0 34px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.save-button { min-height: 38px; padding: 0 16px; color: white; background: var(--green); }
.editor-body { width: min(760px, 100%); height: 100%; margin: 0 auto; padding: clamp(30px, 6vw, 72px); display: flex; flex-direction: column; }
.title-input { width: 100%; padding: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-family: "Newsreader", serif; font-size: clamp(36px, 5vw, 58px); font-weight: 600; line-height: 1.05; letter-spacing: 0; }
.title-input::placeholder, #note-content::placeholder { color: #bdc6c0; }
.tag-row { min-height: 42px; margin: 20px 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; color: var(--muted); }
.tag-row svg { width: 17px; }
#note-content { flex: 1; width: 100%; min-height: 260px; padding: 12px 0 80px; resize: none; border: 0; outline: 0; color: #303a34; background: transparent; font-size: 17px; line-height: 1.75; }

dialog { width: min(420px, calc(100% - 32px)); padding: 0; border: 0; color: var(--ink); background: white; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10, 24, 18, 0.66); }
.wide-dialog { width: min(980px, calc(100% - 32px)); }
.management-modal { padding: 30px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.modal-header .eyebrow, .password-modal .eyebrow { margin-top: 0; }
.modal-header h2, .password-modal h2 { margin: 0; font-family: "Newsreader", serif; font-size: 34px; }
.user-create-form { margin: 26px 0; padding: 18px; display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); align-items: end; gap: 12px; background: var(--paper); }
.user-create-form label, .password-modal label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 600; }
.user-create-form input, .user-create-form select, .password-modal input, .users-table select { min-height: 40px; padding: 0 10px; border: 1px solid var(--line); color: var(--ink); background: white; }
.checkbox-label { min-height: 40px; display: flex !important; grid-template-columns: none !important; flex-direction: row; align-items: center; gap: 9px !important; }
.checkbox-label input { width: 18px; min-height: 18px; padding: 0; accent-color: var(--green); }
.table-wrap { max-height: 52vh; overflow: auto; }
.users-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.users-table th { padding: 10px; color: var(--muted); font-size: 11px; text-align: left; text-transform: uppercase; }
.users-table td { padding: 12px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
.users-table td:first-child { font-weight: 600; }
.status-toggle { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #9ba49f; }
.status-dot.active { background: #27a568; }
.row-actions { display: flex; gap: 4px; }
.row-actions .icon-button:disabled { cursor: not-allowed; opacity: 0.3; }
.text-button { min-height: 38px; padding: 0 13px; border: 1px solid var(--line); color: var(--ink); background: white; }
.password-modal { padding: 34px; display: grid; gap: 18px; }
.modal-copy { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.temporary-secret { min-height: 54px; padding: 0 8px 0 14px; border: 1px solid var(--line); background: var(--paper); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.temporary-secret code { overflow-wrap: anywhere; font-size: 14px; }
.voice-modal { position: relative; padding: 48px 32px 38px; display: grid; justify-items: center; text-align: center; }
.close-button { position: absolute; top: 10px; right: 10px; }
.record-pulse { width: 92px; height: 92px; margin-bottom: 18px; display: grid; place-items: center; border: 12px solid #f8d7d0; border-radius: 50%; color: white; background: var(--coral); }
.record-pulse svg { width: 32px; height: 32px; }
.record-pulse.active { animation: pulse 1.4s infinite; }
.voice-modal h2 { margin: 0; font-family: "Newsreader", serif; font-size: 30px; }
.voice-modal time { margin: 12px 0 24px; font-variant-numeric: tabular-nums; font-size: 24px; }
.record-button { width: 100%; }
.toast { position: fixed; z-index: 20; right: 22px; bottom: 22px; max-width: min(390px, calc(100% - 44px)); padding: 13px 17px; color: white; background: var(--ink); box-shadow: var(--shadow); transform: translateY(90px); opacity: 0; transition: 180ms ease; }
.toast.visible { transform: translateY(0); opacity: 1; }
@keyframes pulse { 50% { box-shadow: 0 0 0 18px rgba(232, 97, 70, 0.16); } }

@media (max-width: 900px) {
  .workspace-shell { grid-template-columns: 78px 320px 1fr; }
  .sidebar { padding-inline: 12px; }
  .sidebar-brand strong, .new-note-button span, .nav-item span, .nav-item b, .sidebar-footer span { display: none; }
  .sidebar-brand, .new-note-button { justify-content: center; }
  .nav-item { grid-template-columns: 1fr; justify-items: center; padding: 0; }
}

@media (max-width: 680px) {
  .login-shell { width: 100%; min-height: 100dvh; margin: 0; grid-template-columns: 1fr; border: 0; }
  .brand-panel { min-height: 270px; padding: 34px 22px; justify-content: flex-start; }
  .brand-panel::after { right: -175px; bottom: -130px; opacity: 0.38; }
  .brand-panel h1 { font-size: 58px; }
  .brand-copy { margin: 14px 0 0; font-size: 15px; }
  .brand-lines { display: none; }
  .login-form { padding: 38px 22px; }
  .login-form h2 { font-size: 34px; }
  .workspace-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .notes-panel { padding: 0 18px; border: 0; }
  .mobile-header { min-height: 66px; display: flex; align-items: center; justify-content: space-between; }
  .panel-heading { padding-top: 18px; }
  .panel-heading h2 { font-size: 34px; }
  .notes-list { margin-inline: -18px; }
  .editor-panel { position: fixed; z-index: 5; inset: 0; transform: translateX(100%); transition: transform 180ms ease; }
  .editor-panel.open { transform: translateX(0); }
  .editor-toolbar { min-height: 62px; padding: 0 14px; }
  .mobile-only { display: grid; }
  .editor-body { padding: 34px 24px; }
  .title-input { font-size: 39px; }
  .management-modal { padding: 22px 16px; }
  .user-create-form { grid-template-columns: 1fr; }
  .users-table { min-width: 720px; }
  .password-modal { padding: 28px 22px; }
}