:root {
  --ink: #374151;
  --muted: #8b93a1;
  --pink: #f49aab;
  --pink-dark: #e77e94;
  --pink-soft: #fff0f3;
  --cream: #fffaf3;
  --yellow: #f6c968;
  --blue: #8dcbd1;
  --green: #82c8a0;
  --white: #ffffff;
  --line: #eee9e5;
  --shadow: 0 12px 36px rgba(112, 84, 79, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 8%, rgba(244, 154, 171, 0.12), transparent 25%),
    var(--cream);
  font-family: "Nunito", "Noto Sans JP", sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.app-shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 32px 22px 24px;
  background: rgba(255, 255, 255, 0.76);
  border-right: 1px solid rgba(238, 233, 229, 0.9);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  margin: 0 8px 40px;
}

.brand-mochi {
  width: 46px;
  height: 42px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 22px;
  font-weight: 800;
  background: var(--pink);
  border-radius: 50% 50% 45% 45%;
  box-shadow: inset 0 -4px 0 rgba(179, 73, 94, 0.09);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 18px; }
.brand small { color: var(--muted); margin-top: 1px; }

.nav-list { display: grid; gap: 8px; }
.nav-item {
  border: 0;
  background: transparent;
  border-radius: 14px;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-weight: 700;
  text-align: left;
  transition: .2s ease;
}
.nav-item > span {
  width: 25px;
  text-align: center;
  font-size: 19px;
}
.nav-item:hover { background: #fff6f7; transform: translateX(2px); }
.nav-item.active { color: var(--pink-dark); background: var(--pink-soft); }
.badge {
  margin-left: auto;
  min-width: 23px;
  padding: 2px 7px;
  border-radius: 20px;
  color: white;
  background: var(--pink);
  font-size: 12px;
  text-align: center;
}

.sidebar-card {
  margin-top: auto;
  padding: 20px 16px;
  border-radius: 20px;
  text-align: center;
  background: #fff6dd;
}
.mini-mascot { font-size: 28px; color: #9a785b; margin-bottom: 6px; }
.sidebar-card strong { font-size: 14px; }
.sidebar-card p { margin: 6px 0 0; font-size: 12px; line-height: 1.6; color: #8e765f; }
.settings-button {
  margin-top: 16px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 10px;
}

main { width: min(1120px, calc(100% - 64px)); margin: 0 auto; padding: 38px 0 70px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.topbar h1 { margin: 5px 0 0; font-size: clamp(22px, 3vw, 30px); letter-spacing: -.03em; }
.eyebrow, .soft-label { margin: 0; color: var(--pink-dark); font-size: 11px; font-weight: 800; letter-spacing: .13em; }
.streak-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid #f4e6dc;
  border-radius: 18px;
  background: rgba(255,255,255,.7);
}
.streak-pill > span { font-size: 25px; }
.streak-pill strong, .streak-pill small { display: block; }
.streak-pill small { color: var(--muted); font-size: 10px; }
.menu-button { display: none; border: 0; background: transparent; font-size: 24px; }
.mobile-settings-button { display: none; border: 0; background: transparent; font-size: 21px; cursor: pointer; }

.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.card { background: rgba(255,255,255,.92); border: 1px solid rgba(238,233,229,.86); box-shadow: var(--shadow); }
.dashboard-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; }
.progress-card { min-height: 206px; border-radius: 26px; padding: 30px 34px; display: flex; align-items: center; justify-content: space-between; gap: 30px; }
.progress-copy { flex: 1; }
.progress-copy h2, .section-heading h2 { margin: 6px 0; font-size: 21px; }
.progress-copy p { color: var(--muted); margin: 4px 0 22px; font-size: 14px; }
.progress-track { height: 10px; overflow: hidden; border-radius: 10px; background: #f4efeb; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--pink), #f8b8a0); transition: width .4s ease; }
.progress-meta { display: flex; justify-content: space-between; margin-top: 9px; font-size: 13px; }
.progress-ring {
  --progress: 0deg;
  width: 118px; height: 118px; border-radius: 50%;
  background: conic-gradient(var(--pink) var(--progress), #f5efea 0);
  display: grid; place-items: center; position: relative; flex: 0 0 auto;
}
.progress-ring::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: white; }
.progress-ring div { position: relative; z-index: 1; text-align: center; }
.progress-ring strong, .progress-ring small { display: block; }
.progress-ring strong { font-size: 22px; }
.progress-ring small { color: var(--muted); font-size: 11px; }

.summary-card {
  border-radius: 26px;
  padding: 25px 28px;
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 13px 16px;
}
.summary-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 15px; font-weight: 800; }
.summary-icon.pink { background: #fff0f3; color: var(--pink-dark); }
.summary-icon.yellow { background: #fff7dd; color: #d49c29; }
.summary-icon.blue { background: #eaf7f8; color: #5ca5ad; }
.summary-card strong, .summary-card span { display: block; }
.summary-card strong { font-size: 21px; line-height: 1; }
.summary-card span { color: var(--muted); font-size: 12px; margin-top: 5px; }

.section-heading { margin: 38px 2px 16px; display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.section-heading h2 { margin-bottom: 0; }
.study-area { max-width: 760px; margin: 0 auto; }
.word-card { position: relative; border-radius: 28px; padding: 26px 36px 24px; overflow: hidden; }
.word-card::before {
  content: "••";
  position: absolute; right: -30px; bottom: -65px;
  width: 180px; height: 180px; border-radius: 50%;
  color: rgba(244,154,171,.18); font-size: 65px; letter-spacing: 15px;
  background: #fff7f8;
}
.heart-button { position: absolute; right: 28px; top: 24px; z-index: 2; border: 0; background: transparent; color: var(--pink); cursor: pointer; font-size: 30px; line-height: 1; }
.heart-button.active { color: var(--pink-dark); }
.word-topline { display: flex; align-items: center; justify-content: space-between; padding-right: 45px; font-size: 12px; }
.level-chip { padding: 5px 10px; border-radius: 20px; color: var(--pink-dark); background: var(--pink-soft); font-weight: 800; }
.word-main { text-align: center; padding: 35px 0 28px; position: relative; z-index: 1; }
.reading { margin: 0; color: var(--pink-dark); letter-spacing: .14em; font-family: "Noto Sans JP", sans-serif; }
.word-main h2 { margin: 4px 0 9px; font-size: clamp(46px, 7vw, 66px); font-family: "Noto Sans JP", sans-serif; font-weight: 500; }
.meaning { margin: 0; font-size: 17px; }
.example-toggle { border: 0; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; position: relative; z-index: 1; }
.example-box { margin-top: 15px; padding: 15px 17px; border-radius: 14px; background: #faf8f6; position: relative; z-index: 1; }
.example-box p { margin: 0 0 5px; font-family: "Noto Sans JP", sans-serif; }
.example-box span { color: var(--muted); font-size: 13px; }

.study-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.action-button { border: 0; border-radius: 18px; padding: 16px; cursor: pointer; display: grid; grid-template-columns: 35px 1fr; text-align: left; box-shadow: var(--shadow); transition: .2s ease; }
.action-button:hover { transform: translateY(-2px); }
.action-button > span { grid-row: span 2; align-self: center; font-size: 22px; }
.action-button strong { font-size: 14px; }
.action-button small { opacity: .7; }
.action-button.again { background: #fff3df; color: #9a6a29; }
.action-button.mastered { background: #e9f7ef; color: #4d8e6b; }

.empty-state { text-align: center; padding: 60px 30px; border-radius: 28px; }
.celebration { font-size: 50px; color: var(--pink); }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { color: var(--muted); }
.primary-button, .ghost-button, .danger-button {
  border-radius: 12px; padding: 10px 16px; cursor: pointer; font-weight: 700;
}
.primary-button { border: 0; background: var(--pink); color: white; }
.ghost-button { border: 1px solid var(--line); background: white; }
.danger-button { border: 1px solid #f4ccd2; background: #fff4f5; color: #c95f72; }

.word-list { display: grid; gap: 12px; }
.list-card {
  display: grid; grid-template-columns: 70px minmax(100px, 1fr) 1.5fr auto;
  align-items: center; gap: 18px; padding: 18px 22px; border-radius: 18px;
}
.list-card .list-kanji { font-size: 25px; font-family: "Noto Sans JP", sans-serif; }
.list-card .list-reading { color: var(--pink-dark); font-family: "Noto Sans JP", sans-serif; font-size: 13px; }
.list-card .list-meaning { color: var(--muted); }
.list-actions { display: flex; gap: 7px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 12px; background: white; cursor: pointer; }
.icon-button.favorite { color: var(--pink-dark); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.new { background: #c7cbd1; }
.status-dot.review { background: var(--yellow); }
.status-dot.mastered { background: var(--green); }
.empty-list { padding: 55px 25px; text-align: center; color: var(--muted); border: 1px dashed #e4ddd7; border-radius: 20px; }

.library-heading { align-items: center; }
.search-box { display: flex; align-items: center; gap: 8px; min-width: 290px; border: 1px solid var(--line); background: white; border-radius: 14px; padding: 9px 13px; }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-chip { border: 1px solid var(--line); background: white; padding: 7px 13px; border-radius: 20px; cursor: pointer; font-size: 12px; }
.filter-chip.active { border-color: #f3bbc5; color: var(--pink-dark); background: var(--pink-soft); }
.compact .list-card { padding-block: 13px; box-shadow: none; }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(55, 65, 81, .28); backdrop-filter: blur(6px); }
.modal { width: min(520px, 100%); border-radius: 26px; padding: 32px; position: relative; }
.modal h2 { margin: 5px 0 24px; }
.modal-close { position: absolute; right: 20px; top: 16px; border: 0; background: transparent; font-size: 28px; cursor: pointer; }
.field { display: grid; gap: 7px; font-weight: 700; }
.field input { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; outline: none; }
.install-panel {
  margin-top: 18px;
  padding: 17px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-radius: 18px;
  color: #725961;
  background: var(--pink-soft);
}
.install-panel p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.install-panel .primary-button { flex: 0 0 auto; }
.import-panel { margin-top: 22px; padding: 20px; border-radius: 18px; background: #faf8f6; }
.import-panel p, .fine-print { color: var(--muted); font-size: 13px; line-height: 1.6; }
.import-panel input { width: 100%; margin: 10px 0 16px; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.fine-print { margin-bottom: 0; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 28px; transform: translate(-50%, 20px); padding: 11px 18px; border-radius: 14px; color: white; background: #4b5563; opacity: 0; pointer-events: none; transition: .25s ease; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    z-index: 10;
    inset: auto 0 0;
    width: 100%;
    height: auto;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    transform: none;
    border: 0;
    border-top: 1px solid var(--line);
    background: rgba(255,255,255,.94);
    box-shadow: 0 -8px 30px rgba(112,84,79,.08);
  }
  .sidebar .brand, .sidebar-card, .settings-button { display: none; }
  .nav-list { grid-template-columns: repeat(4, 1fr); gap: 2px; }
  .nav-item {
    position: relative;
    min-width: 0;
    padding: 7px 3px;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    border-radius: 12px;
    font-size: 10px;
    text-align: center;
    white-space: nowrap;
  }
  .nav-item:hover { transform: none; }
  .nav-item > span { width: auto; height: 24px; font-size: 19px; }
  .nav-item .badge { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; min-width: 18px; padding: 1px 5px; font-size: 9px; }
  main { width: min(100% - 34px, 760px); padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  .mobile-settings-button { display: block; }
  .topbar { justify-content: flex-start; }
  .streak-pill { margin-left: auto; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .summary-card { grid-template-columns: repeat(3, 48px 1fr); }
}

@media (max-width: 620px) {
  main { width: min(100% - 24px, 520px); }
  .topbar { gap: 12px; }
  .eyebrow { display: none; }
  .topbar h1 { font-size: 18px; }
  .topbar > div:nth-child(2) { min-width: 0; }
  .topbar h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .streak-pill { padding: 8px 10px; }
  .streak-pill small { display: none; }
  .progress-card { padding: 24px; }
  .progress-ring { width: 90px; height: 90px; }
  .summary-card { grid-template-columns: 44px 1fr; }
  .word-card { padding: 22px 20px; }
  .study-actions { grid-template-columns: 1fr; }
  .list-card { grid-template-columns: 55px 1fr auto; gap: 10px; }
  .list-card .list-meaning { grid-column: 1 / -1; }
  .library-heading { align-items: stretch; flex-direction: column; }
  .search-box { min-width: 0; }
  .install-panel { align-items: stretch; flex-direction: column; }
  .install-panel .primary-button { width: 100%; }
  .modal { max-height: calc(100dvh - 28px); overflow-y: auto; padding: 27px 22px; }
  .toast { bottom: calc(82px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100% - 30px); text-align: center; }
}

@media (display-mode: standalone) {
  body { user-select: none; -webkit-tap-highlight-color: transparent; }
  input { user-select: text; }
}
