/* ==========================================================================
   rubi sewako — shared components
   ========================================================================== */

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */
.top-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 20px var(--sp-6) 12px;
  padding:
    calc(20px + env(safe-area-inset-top, 0px))
    max(var(--sp-6), env(safe-area-inset-right, 0px))
    12px
    max(var(--sp-6), env(safe-area-inset-left, 0px));
  transition: background-color .3s var(--ease), backdrop-filter .3s var(--ease), border-color .3s var(--ease);
  border-bottom: 1px solid transparent;
}
.top-bar.is-stuck {
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border-bottom-color: var(--line-soft);
}

.logo {
  font-family: var(--font-script);
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
  text-shadow: 0 2px 12px rgba(0, 0, 0, .5);
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  transition: opacity .2s var(--ease);
}
.logo__first {
  font-size: 31px;
  letter-spacing: .5px;
}
.logo__last {
  font-size: 25px;
  letter-spacing: 1.2px;
  color: var(--ink-2);
  opacity: .92;
}
.logo:hover { opacity: .85; }
.logo .star {
  font-size: 20px;
  line-height: 1;
  align-self: flex-start;
  margin-left: -2px;
  color: var(--glow);
  animation: twinkle 4.5s var(--ease) infinite;
}
@keyframes twinkle {
  0%, 100% { opacity: .95; transform: rotate(0deg); }
  50%      { opacity: .55; transform: rotate(24deg); }
}

.top-actions { display: flex; align-items: center; gap: var(--sp-5); }

.action-btn {
  color: var(--ink);
  opacity: .88;
  display: grid;
  place-items: center;
  transition: transform .2s var(--ease), opacity .2s var(--ease);
}
.action-btn:hover { opacity: 1; transform: scale(1.1); }
.action-btn:active { transform: scale(.94); }

/* Back button used on subscreens */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-4);
  padding: 6px 12px 6px 8px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-soft);
  background: var(--card);
  transition: color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.back-btn:hover { color: var(--ink-2); border-color: var(--line); transform: translateX(-2px); }

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.chalk-card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: inset 0 0 14px color-mix(in srgb, var(--glow) 5%, transparent), var(--shadow-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: relative;
}
.chalk-card--tap {
  cursor: pointer;
  transition: transform .22s var(--ease), border-color .22s var(--ease), background-color .22s var(--ease);
  text-align: left;
  width: 100%;
  display: block;
}
.chalk-card--tap:hover { border-color: var(--line-strong); background: var(--card-hover); transform: translateY(-2px); }
.chalk-card--tap:active { transform: scale(.985); }

/* --------------------------------------------------------------------------
   Section headers
   -------------------------------------------------------------------------- */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: 0 2px;
}
.section-title {
  font-family: var(--font-script);
  font-size: 32px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: .5px;
  color: var(--ink);
}
.section-dash {
  width: 24px; height: 2px;
  margin-top: 4px;
  border-radius: 2px;
  background: var(--line-strong);
}
.link-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-4);
  transition: color .2s var(--ease), transform .2s var(--ease);
}
.link-more:hover { color: var(--ink-2); transform: translateX(2px); }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.brush-btn {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  padding: 5px 22px;
  border-radius: 14px 18px 12px 16px / 16px 12px 18px 14px;
  color: var(--accent-ink);
  font-family: var(--font-script);
  font-size: 19px;
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 45%, transparent);
  transition: transform .2s var(--ease), filter .2s var(--ease);
}
.brush-btn:hover { transform: scale(1.05); filter: brightness(1.12); }
.brush-btn:active { transform: scale(.96); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  transition: all .2s var(--ease);
}
.btn:hover { border-color: var(--line-strong); color: var(--ink); background: var(--card-hover); }
.btn:active { transform: scale(.97); }
.btn--primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  border-color: transparent;
  color: var(--accent-ink);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent);
}
.btn--primary:hover { filter: brightness(1.1); background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%); }
.btn--ghost { background: none; border-color: var(--line-soft); }
.btn--danger { color: var(--rose); border-color: color-mix(in srgb, var(--rose) 45%, transparent); }
.btn--danger:hover { background: color-mix(in srgb, var(--rose) 14%, transparent); color: var(--rose); }
.btn--full { width: 100%; }
.btn--sm { padding: 8px 15px; font-size: 13px; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line-soft);
  color: var(--ink-3);
  background: var(--card);
  transition: all .2s var(--ease);
}
.icon-btn:hover { color: var(--ink); border-color: var(--line); transform: scale(1.06); }
.icon-btn:active { transform: scale(.93); }
.icon-btn.is-on { color: var(--warm); border-color: color-mix(in srgb, var(--warm) 50%, transparent); }

/* --------------------------------------------------------------------------
   Chips
   -------------------------------------------------------------------------- */
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
  margin: 0 -2px;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-soft);
  background: var(--card);
  color: var(--ink-4);
  font-size: 12.5px;
  white-space: nowrap;
  transition: all .2s var(--ease);
}
.chip:hover { color: var(--ink-2); border-color: var(--line); }
.chip.is-active {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--card-hover);
  box-shadow: 0 0 14px color-mix(in srgb, var(--glow) 12%, transparent);
}

/* --------------------------------------------------------------------------
   Form fields
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field__label {
  font-family: var(--font-script);
  font-size: 18px;
  color: var(--ink-2);
}
.input, .textarea, .select {
  width: 100%;
  background: color-mix(in srgb, var(--bg-deep) 45%, transparent);
  border: 1.5px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 12px 14px;
  color: var(--ink);
  font-size: 15px;
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-5); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--bg-deep) 62%, transparent);
}
.textarea { resize: vertical; min-height: 120px; line-height: 1.65; }
.select { appearance: none; cursor: pointer; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238e9fc4' stroke-width='2' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
}
.switch-row:last-child { border-bottom: none; }
.switch-row__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.switch-row__title { font-size: 14.5px; color: var(--ink-2); }
.switch-row__sub { font-size: 12px; color: var(--ink-5); line-height: 1.4; }

.switch {
  flex: none;
  width: 46px; height: 27px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg-deep) 50%, transparent);
  position: relative;
  transition: background-color .25s var(--ease), border-color .25s var(--ease);
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: var(--ink-4);
  transition: transform .25s var(--ease-out), background-color .25s var(--ease);
}
.switch[aria-checked='true'] {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  border-color: transparent;
}
.switch[aria-checked='true']::after { transform: translateX(19px); background: var(--accent-ink); }

/* Stepper for numeric settings */
.stepper { display: flex; align-items: center; gap: 10px; flex: none; }
.stepper__val {
  font-family: var(--font-serif);
  font-size: 22px;
  min-width: 46px;
  text-align: center;
  color: var(--ink);
}
.stepper button {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line-soft);
  color: var(--ink-3);
  display: grid; place-items: center;
  font-size: 17px;
  line-height: 1;
  transition: all .18s var(--ease);
}
.stepper button:hover { color: var(--ink); border-color: var(--line); }
.stepper button:active { transform: scale(.9); }
.stepper button:disabled { opacity: .3; cursor: not-allowed; }

/* --------------------------------------------------------------------------
   Bottom navigation
   -------------------------------------------------------------------------- */
.bottom-nav {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  height: 76px;
  height: calc(76px + env(safe-area-inset-bottom, 0px));
  padding: 0 14px;
  padding:
    0
    max(14px, env(safe-area-inset-right, 0px))
    env(safe-area-inset-bottom, 0px)
    max(14px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  border-top: 1px solid var(--line-soft);
  border-radius: 26px 26px 0 0;
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  display: flex;
  align-items: center;
  justify-content: space-around;
  box-shadow: var(--shadow-nav);
}
.nav-leaf {
  position: absolute;
  bottom: 0;
  width: 55px; height: 46px;
  color: var(--glow);
  opacity: .14;
  pointer-events: none;
}
.nav-leaf--left { left: 0; }
.nav-leaf--right { right: 0; transform: scaleX(-1); }

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  position: relative;
  color: var(--ink-5);
  transition: color .22s var(--ease), transform .22s var(--ease);
}
.nav-item:hover { color: var(--ink-3); }
.nav-item:active { transform: scale(.93); }
.nav-item.is-active { color: var(--ink); }
.nav-item.is-active::after {
  content: '';
  position: absolute;
  bottom: -5px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 7px color-mix(in srgb, var(--ink) 80%, transparent);
  animation: pop .3s var(--ease-out);
}
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }

.nav-icon { width: 21px; height: 21px; stroke-width: 1.6; }
.nav-label { font-size: 10.5px; letter-spacing: .2px; }

.nav-add-btn {
  display: grid;
  place-items: center;
  margin: 0 2px;
  transition: transform .25s var(--ease);
}
.nav-add-btn:hover { transform: scale(1.08) rotate(90deg); }
.nav-add-btn:active { transform: scale(.94) rotate(90deg); }
.add-circle {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 55%, var(--bg-deep)) 100%);
  border: 1px solid color-mix(in srgb, var(--glow) 30%, transparent);
  display: grid; place-items: center;
  color: var(--accent-ink);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 40%, transparent);
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */
.toast {
  position: absolute;
  top: 74px;
  top: calc(74px + env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 90;
  transform: translateX(-50%) translateY(-18px);
  max-width: 84%;
  background: color-mix(in srgb, var(--bg-raised) 94%, transparent);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 17px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  color: var(--ink);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
  box-shadow: var(--shadow-lift);
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --------------------------------------------------------------------------
   Bottom sheet / dialog
   -------------------------------------------------------------------------- */
.sheet-root { position: absolute; inset: 0; z-index: 80; pointer-events: none; }
.sheet-root:empty { display: none; }

.sheet-scrim {
  position: absolute;
  inset: 0;
  background: rgba(4, 7, 16, .6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: auto;
  animation: fade-in .25s var(--ease) both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  max-height: 88%;
  overflow-y: auto;
  scrollbar-width: none;
  pointer-events: auto;
  background: var(--card-solid);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  padding: 12px var(--sp-6) var(--sp-7);
  padding:
    12px
    max(var(--sp-6), env(safe-area-inset-right, 0px))
    calc(var(--sp-7) + env(safe-area-inset-bottom, 0px))
    max(var(--sp-6), env(safe-area-inset-left, 0px));
  box-shadow: 0 -18px 50px rgba(0, 0, 0, .55);
  animation: sheet-up .38s var(--ease-out) both;
}
.sheet::-webkit-scrollbar { display: none; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }

.sheet__grip {
  width: 38px; height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: 0 auto 16px;
}
.sheet__title {
  font-family: var(--font-script);
  font-size: 27px;
  color: var(--ink);
  margin-bottom: 4px;
}
.sheet__sub { font-size: 13px; color: var(--ink-4); margin-bottom: 18px; line-height: 1.5; }
.sheet__list { display: flex; flex-direction: column; gap: 8px; }
.sheet__actions { display: flex; gap: 10px; margin-top: 22px; }
.sheet__actions .btn { flex: 1; }

.sheet-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg-deep) 32%, transparent);
  text-align: left;
  transition: all .2s var(--ease);
}
.sheet-option:hover { border-color: var(--line-strong); background: var(--card-hover); transform: translateX(3px); }
.sheet-option__icon {
  width: 38px; height: 38px;
  flex: none;
  border-radius: 12px;
  display: grid; place-items: center;
  color: var(--glow);
  background: color-mix(in srgb, var(--glow) 10%, transparent);
  border: 1px solid var(--line-soft);
}
.sheet-option__icon svg { width: 19px; height: 19px; }
.sheet-option__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sheet-option__title { font-size: 14.5px; color: var(--ink); }
.sheet-option__sub { font-size: 12px; color: var(--ink-5); }
.sheet-option.is-selected { border-color: var(--line-strong); background: var(--card-hover); }
.sheet-option__check { margin-left: auto; color: var(--glow); opacity: 0; transition: opacity .2s; }
.sheet-option.is-selected .sheet-option__check { opacity: 1; }

/* --------------------------------------------------------------------------
   Empty states
   -------------------------------------------------------------------------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 46px 26px;
  color: var(--ink-4);
}
.empty__art { width: 96px; height: 96px; opacity: .8; }
.empty__title { font-family: var(--font-script); font-size: 25px; color: var(--ink-2); }
.empty__body { font-size: 13px; max-width: 260px; line-height: 1.6; color: var(--ink-5); }

/* --------------------------------------------------------------------------
   Misc
   -------------------------------------------------------------------------- */
.divider { height: 1px; background: var(--line-soft); margin: var(--sp-5) 0; }
.v-divider { width: 1px; height: 54px; background: var(--line-soft); }

.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-soft);
  font-size: 11px;
  color: var(--ink-4);
  background: color-mix(in srgb, var(--bg-deep) 30%, transparent);
}

@media (min-width: 800px) {
  .top-bar {
    padding: 26px max(32px, calc((100vw - 1180px) / 2)) 14px;
    padding-right: max(32px, calc((100vw - 1180px) / 2), env(safe-area-inset-right, 0px));
    padding-left: max(32px, calc((100vw - 1180px) / 2), env(safe-area-inset-left, 0px));
  }

  .bottom-nav {
    height: 78px;
    height: calc(78px + env(safe-area-inset-bottom, 0px));
    padding: 0 max(32px, calc((100vw - 660px) / 2));
    padding-right: max(32px, calc((100vw - 660px) / 2), env(safe-area-inset-right, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: max(32px, calc((100vw - 660px) / 2), env(safe-area-inset-left, 0px));
    border-radius: 0;
  }

  .nav-item { min-width: 76px; }
  .nav-leaf { opacity: .08; }

  .sheet {
    left: 50%;
    right: auto;
    width: min(620px, calc(100vw - 48px));
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    animation-name: sheet-up-wide;
  }

  @keyframes sheet-up-wide {
    from { transform: translate(-50%, 100%); }
    to { transform: translate(-50%, 0); }
  }
}
