:root {
  --g9: #062a20; --g8: #0b3d2e; --g7: #10523d; --g6: #17684d;
  --gold: #c9973f; --gold-l: #f3d58a;
  --bg: #f5f3ec; --card: #fff; --ink: #17231e; --muted: #66736d; --line: #e4e0d4;
  --danger: #b42318; --r: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 Inter, system-ui, sans-serif; color: var(--ink); background: var(--bg); }
h1, h2 { font-family: "Cormorant Garamond", Georgia, serif; margin: 0; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
[hidden] { display: none !important; }

.btn { border: 1px solid transparent; border-radius: 10px; padding: .7em 1.2em; font: 600 .9rem Inter, sans-serif; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: .2s; }
.btn--primary { background: var(--g8); color: #fff; }
.btn--primary:hover { background: var(--g6); }
.btn--primary:disabled { opacity: .6; cursor: wait; }
.btn--ghost { border-color: rgba(255, 255, 255, .25); color: #fff; }
.btn--ghost:hover { background: rgba(255, 255, 255, .1); }
.btn--ghost-dark { border-color: var(--line); color: var(--g8); background: #fff; }
.btn--ghost-dark:hover { border-color: var(--g8); }
.btn--danger { background: #fff; color: var(--danger); border-color: #f1c6c2; }
.btn--danger:hover { background: var(--danger); color: #fff; }
.btn--link { background: none; border: 0; color: inherit; opacity: .8; padding: .5em 0; text-decoration: underline; }
.btn--block { width: 100%; }

input, select, textarea { width: 100%; font: inherit; padding: .65em .8em; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); transition: border .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--g6); box-shadow: 0 0 0 3px rgba(23, 104, 77, .15); }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: .88rem; }
textarea { resize: vertical; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(900px 500px at 70% 0, var(--g7), var(--g9)); }
.auth__card { width: min(400px, 100%); background: #fff; border-radius: 22px; padding: 34px; display: grid; gap: 14px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .5); }
.auth__logo { height: 64px; margin: 0 auto 6px; }
.auth h1 { text-align: center; font-size: 2rem; color: var(--g8); }
.auth p { text-align: center; margin: 0; }
.auth__back { text-align: center; color: var(--muted); font-size: .88rem; }
.err { color: var(--danger); min-height: 1.2em; font-size: .88rem; }

/* Layout */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: linear-gradient(180deg, var(--g8), var(--g9)); color: #fff; padding: 22px 16px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100vh; }
.side__brand img { height: 46px; margin: 0 8px; }
.side__nav { display: grid; gap: 4px; }
.side__nav button { display: flex; align-items: center; gap: 12px; background: none; border: 0; color: rgba(255, 255, 255, .78); font: 500 .93rem Inter, sans-serif; padding: 11px 12px; border-radius: 10px; cursor: pointer; text-align: left; transition: .2s; }
.side__nav svg { width: 20px; height: 20px; }
.side__nav button:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.side__nav button.is-active { background: rgba(243, 213, 138, .15); color: var(--gold-l); }
.side__foot { margin-top: auto; display: grid; gap: 6px; text-align: center; }
.main { padding: 28px 36px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.topbar h1 { font-size: 2.2rem; color: var(--g8); line-height: 1.1; }
.topbar p { margin: 2px 0 0; }
.user { margin-left: auto; background: #fff; border: 1px solid var(--line); padding: 6px 14px; border-radius: 99px; font-size: .85rem; }
.menu-btn { display: none; font-size: 1.4rem; border: 0; background: #fff; width: 42px; height: 42px; border-radius: 10px; cursor: pointer; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 24px; box-shadow: 0 4px 16px -10px rgba(0, 0, 0, .15); }
.card.narrow { max-width: 460px; display: grid; gap: 14px; }
.card h2 { color: var(--g8); font-size: 1.5rem; }
.card__foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.grid-form h2 { margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.grid-form h2:first-child { margin-top: 0; padding-top: 0; border: 0; }
.full { grid-column: 1 / -1; }

.switch { flex-direction: row; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; }
.switch span { width: 42px; height: 24px; border-radius: 99px; background: #cfd4d1; position: relative; transition: .2s; flex: none; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input:checked + span { background: var(--g6); }
.switch input:checked + span::after { left: 21px; }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(23, 104, 77, .3); }

/* Prayer rows */
.prayer-rows { display: grid; gap: 12px; margin-bottom: 18px; }
.p-row { display: grid; grid-template-columns: 170px 1fr; gap: 16px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: #fcfbf7; }
.p-row__name { font-family: "Cormorant Garamond", serif; font-size: 1.5rem; font-weight: 700; color: var(--g8); line-height: 1; }
.p-row__name small { display: block; font: 400 1rem Amiri, serif; color: var(--gold); margin-top: 4px; }
.p-row__ctrl { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.p-row__ctrl input[type=time] { width: 190px; font-size: 1.1rem; font-weight: 600; }
.p-row__ctrl input[type=number] { width: 80px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg label { flex-direction: row; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 0; }
.seg span { padding: .55em .9em; font-size: .85rem; }
.seg input:checked + span { background: var(--g8); color: #fff; }
.hint { font-size: .82rem; color: var(--muted); }

/* Table */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px; border-bottom: 1px solid var(--line); }
.table td:last-child { width: 50px; text-align: right; }
.icon-del { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--danger); cursor: pointer; font-size: 1.1rem; }
.icon-del:hover { background: #fdecea; }
.empty-row { text-align: center; color: var(--muted); padding: 20px !important; }

/* Events */
.toolbar { display: flex; gap: 12px; margin-bottom: 18px; }
.toolbar input { max-width: 340px; }
.toolbar .btn { margin-left: auto; }
.event-list { display: grid; gap: 12px; }
.ev { display: grid; grid-template-columns: 70px 1fr auto; gap: 16px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; cursor: pointer; transition: .2s; }
.ev:hover { border-color: var(--g6); box-shadow: 0 6px 20px -12px rgba(0, 0, 0, .3); }
.ev.is-past { opacity: .55; }
.ev__date { text-align: center; background: var(--g8); color: #fff; border-radius: 10px; padding: 6px; line-height: 1.1; }
.ev__date b { display: block; font-size: 1.4rem; }
.ev__date small { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; }
.ev__title { font-weight: 600; }
.ev__meta { font-size: .85rem; color: var(--muted); }
.badge { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; padding: 3px 8px; border-radius: 99px; background: #f6ecd6; color: #8a6322; }
.badge--past { background: #eee; color: #777; }

/* Quotes */
.quote-rows { display: grid; gap: 14px; margin-top: 14px; }
.q-row { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; grid-template-columns: 220px 1fr 40px; gap: 12px; background: #fcfbf7; }
.q-row textarea { min-height: 80px; }
.q-row .q-main { display: grid; gap: 8px; }

/* Drawer */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer__backdrop { position: absolute; inset: 0; background: rgba(6, 42, 32, .5); animation: fade .2s; }
.drawer__panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(620px, 100%); background: #fff; display: flex; flex-direction: column; animation: slide .3s cubic-bezier(.2, .8, .2, 1); }
.drawer__panel header, .drawer__panel footer { padding: 18px 24px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.drawer__panel footer { border-top: 1px solid var(--line); border-bottom: 0; }
.drawer__panel h2 { font-size: 1.7rem; color: var(--g8); }
.drawer__body { padding: 22px 24px; overflow: auto; flex: 1; align-content: start; }
.x { border: 0; background: none; font-size: 1.8rem; cursor: pointer; color: var(--muted); }
.upload .label { font-weight: 500; font-size: .88rem; display: block; margin-bottom: 6px; }
.upload__row { display: flex; gap: 16px; align-items: flex-start; }
.upload__preview { width: 150px; aspect-ratio: 16/10; border-radius: 10px; background: #eef0ec center/cover; border: 1px dashed var(--line); flex: none; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }

.toast { position: fixed; bottom: 22px; left: 50%; translate: -50% 20px; background: var(--g9); color: #fff; padding: 12px 20px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .3s; z-index: 99; }
.toast.is-show { opacity: 1; translate: -50% 0; }
.toast.is-error { background: var(--danger); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: .3s; }
  .side.is-open { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .4); }
  .menu-btn { display: block; }
  .main { padding: 18px 16px 50px; }
  .grid-form { grid-template-columns: 1fr; }
  .p-row { grid-template-columns: 1fr; }
  .q-row { grid-template-columns: 1fr; }
  .ev { grid-template-columns: 60px 1fr; }
  .ev > :last-child { grid-column: 2; }
  .user { display: none; }
}

.hint { font-weight: 400; }
.portrait-up { display: flex; gap: 16px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fcfbf7; }
.portrait-up__img { width: 84px; height: 84px; border-radius: 50%; background: #e8ece9 center/cover; border: 3px solid var(--gold); flex: none; }
.portrait-up input[type=file] { margin-top: 6px; font-size: .8rem; padding: 6px; }
.links-edit { display: grid; gap: 8px; }
.link-row { display: grid; grid-template-columns: 28px 1fr 2fr 36px; gap: 8px; align-items: center; }
.link-row .handle { cursor: grab; color: var(--muted); text-align: center; user-select: none; }
.link-row.is-drag { opacity: .4; }
.icon-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 8px; }
.icon-pick button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 4px 6px; cursor: pointer; display: grid; justify-items: center; gap: 2px; font: 500 .68rem Inter, sans-serif; color: var(--muted); }
.icon-pick button svg { width: 26px; height: 26px; color: var(--g8); stroke-width: 3; }
.icon-pick button.is-on { border-color: var(--g6); background: #eaf4ef; box-shadow: 0 0 0 2px rgba(23,104,77,.25); color: var(--g8); }
@media (max-width: 860px) { .link-row { grid-template-columns: 24px 1fr 36px; } .link-row input[name=url] { grid-column: 2 / 3; } }
