* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root{
  --paper:#f8f0cf;
  --paper-2:#fff7da;
  --ink:#27241e;
  --line:rgba(103,123,132,.15);
  --rule:rgba(173,120,120,.28);
  --pink:#efc3cf;
  --blue:#c9deea;
  --violet:#d9cbea;
  --shadow:rgba(64,48,28,.16);
}

html, body{
  margin:0;
  width:100%;
  height:100%;
  overflow:hidden;
  overscroll-behavior:none;
  background:#eee8d6;
  color:var(--ink);
  font-family:"YuKyokasho","Yu Kyokasho","Hiragino Maru Gothic ProN","Hiragino Kaku Gothic ProN",
              "Apple SD Gothic Neo","Noto Sans KR",sans-serif;
}

body{
  position:fixed;
  inset:0;
  touch-action:none;
}

button,input{ font:inherit; color:inherit; }
button{ border:0; background:none; }

.app-shell{
  position:fixed;
  inset:0;
  width:100%;
  height:100dvh;
  overflow:hidden;
  background:#e9e2cf;
  padding:
    max(12px, env(safe-area-inset-top))
    10px
    max(10px, env(safe-area-inset-bottom))
    0;
}

.notebook{
  position:absolute;
  left:34px;
  right:8px;
  top:max(14px, env(safe-area-inset-top));
  bottom:max(10px, env(safe-area-inset-bottom));
  min-width:0;
}

.page{
  position:absolute;
  inset:36px 0 0 0;
  overflow:hidden;
  padding:18px 15px 13px 21px;
  background-color:var(--paper);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size:18px 18px;
  border-radius:0 10px 10px 7px;
  box-shadow:0 4px 14px var(--shadow), inset 10px 0 18px rgba(77,55,22,.035);
}

.page.turn-next{ animation:turnNext .25s ease both; transform-origin:left center; }
.page.turn-prev{ animation:turnPrev .25s ease both; transform-origin:left center; }

@keyframes turnNext{
  0%{transform:perspective(800px) rotateY(0deg) translateX(0); filter:brightness(1)}
  48%{transform:perspective(800px) rotateY(-5deg) translateX(-6px); filter:brightness(.97)}
  100%{transform:perspective(800px) rotateY(0deg) translateX(0); filter:brightness(1)}
}
@keyframes turnPrev{
  0%{transform:perspective(800px) rotateY(0deg) translateX(0); filter:brightness(1)}
  48%{transform:perspective(800px) rotateY(5deg) translateX(6px); filter:brightness(.97)}
  100%{transform:perspective(800px) rotateY(0deg) translateX(0); filter:brightness(1)}
}

.tabs{
  position:absolute;
  left:12px;
  top:0;
  height:38px;
  display:flex;
  align-items:flex-end;
  gap:3px;
  z-index:8;
}

.tab{
  position:relative;
  height:32px;
  min-width:63px;
  padding:5px 13px 6px;
  border-radius:9px 9px 0 0;
  box-shadow:0 -1px 4px rgba(72,52,30,.12);
  font-size:15px;
  letter-spacing:.08em;
  touch-action:manipulation;
}
.tab:nth-child(1){ background:var(--pink); }
.tab:nth-child(2){ background:var(--blue); }
.tab:nth-child(3){ background:var(--violet); }

.tab.active{
  height:36px;
  z-index:2;
}
.tab.active::after{
  content:"";
  position:absolute;
  left:0; right:0; bottom:-7px;
  height:9px;
  background:var(--paper);
}
.tab.inactive{ transform:translateY(3px); opacity:.92; }

.spring-rail{
  position:absolute;
  left:0;
  top:max(46px, calc(env(safe-area-inset-top) + 40px));
  bottom:max(18px, env(safe-area-inset-bottom));
  width:48px;
  z-index:9;
  pointer-events:none;
}

.spring{
  position:absolute;
  left:-12px;
  width:54px;
  height:20px;
}
.spring::before{
  content:"";
  position:absolute;
  left:0; top:2px;
  width:46px; height:13px;
  border:4px solid #3c3a35;
  border-right-width:5px;
  border-radius:50%;
  box-shadow:0 1px 1px rgba(255,255,255,.55), 1px 2px 2px rgba(0,0,0,.18);
}
.spring::after{
  content:"";
  position:absolute;
  right:0; top:7px;
  width:11px; height:7px;
  background:#d8cfb2;
  border-radius:50%;
  box-shadow:inset 0 1px 2px rgba(0,0,0,.22);
}

.toolbar{ position:relative; z-index:5; }

.search-wrap{
  height:39px;
  display:flex;
  align-items:center;
  gap:8px;
  padding:0 12px;
  background:rgba(255,250,228,.72);
  border:1.5px solid rgba(113,103,82,.32);
  border-radius:8px 11px 7px 10px;
  box-shadow:0 1px 0 rgba(255,255,255,.7);
  touch-action:manipulation;
}
.search-wrap input{
  min-width:0;
  width:100%;
  border:0;
  outline:0;
  background:transparent;
  font-size:16px;
  letter-spacing:.02em;
  touch-action:auto;
  -webkit-user-select:text;
  user-select:text;
}
.search-wrap input::placeholder{ color:#938d80; }

.search-mark{
  width:15px; height:15px;
  border:2px solid #67635a;
  border-radius:50%;
  position:relative;
  flex:0 0 auto;
}
.search-mark::after{
  content:"";
  position:absolute;
  width:7px; height:2px;
  background:#67635a;
  right:-5px; bottom:-2px;
  transform:rotate(45deg);
  border-radius:1px;
}

.control-row{
  position:relative;
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  margin-top:11px;
  z-index:20;
}

.paper-menu-wrap{ position:relative; }
.paper-menu-wrap.right{ margin-left:auto; }

.paper-btn{
  height:31px;
  min-width:104px;
  padding:4px 11px 5px;
  background:#fff8dc;
  border:1px solid rgba(111,99,76,.28);
  border-radius:4px 7px 5px 3px;
  box-shadow:1px 2px 3px rgba(79,60,31,.08);
  font-size:14px;
  touch-action:manipulation;
}
.chev{ margin-left:7px; font-size:12px; }

.paper-menu{
  position:absolute;
  top:28px;
  left:7px;
  width:116px;
  padding:13px 10px 10px;
  display:flex;
  flex-direction:column;
  gap:2px;
  background:#fff6d8;
  border:1px solid rgba(102,89,66,.2);
  box-shadow:2px 5px 8px rgba(73,53,25,.14);
  transform:scaleY(0);
  transform-origin:top;
  opacity:0;
  pointer-events:none;
  transition:transform .18s ease, opacity .12s ease;
  clip-path:polygon(0 0, 100% 1%, 98% 100%, 2% 98%);
}
.paper-menu-wrap.right .paper-menu{ left:auto; right:5px; width:132px; }

.paper-menu.open{
  transform:scaleY(1);
  opacity:1;
  pointer-events:auto;
}
.paper-menu button{
  position:relative;
  text-align:left;
  padding:7px 7px 7px 10px;
  font-size:14px;
  border-bottom:1px dashed rgba(118,105,78,.17);
  touch-action:manipulation;
}
.paper-menu button:last-child{ border-bottom:0; }
.paper-menu button.selected::after{
  content:"✓";
  position:absolute;
  right:6px;
}

.entries{
  position:absolute;
  left:21px;
  right:15px;
  top:110px;
  bottom:44px;
  overflow:hidden;
  z-index:2;
}

.entry{
  min-height:69px;
  padding:9px 3px 8px 4px;
  border-bottom:1.5px dashed var(--rule);
  display:flex;
  flex-direction:column;
  justify-content:center;
  touch-action:manipulation;
}
.entry:last-child{ border-bottom:0; }

.topline{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:12px;
  min-width:0;
}
.korean{
  font-family:"Apple SD Gothic Neo","Noto Sans KR","YuKyokasho","Yu Kyokasho",sans-serif;
  font-size:23px;
  font-weight:600;
  letter-spacing:.035em;
  line-height:1.1;
  min-width:0;
}
.reading{
  color:#425c87;
  font-size:13px;
  line-height:1.25;
  text-align:right;
  flex:0 1 48%;
}
.meaning{
  margin-top:5px;
  color:#b74e54;
  font-size:15px;
  line-height:1.25;
}
.entry.long .topline{
  display:block;
}
.entry.long .reading{
  display:block;
  margin-top:4px;
  text-align:left;
  max-width:100%;
  font-size:12.5px;
}
.entry.long .meaning{ margin-top:4px; }

.empty{
  position:absolute;
  inset:30% 0 auto 0;
  text-align:center;
  color:#746f65;
  font-size:15px;
}

.pager{
  position:absolute;
  left:0; right:0; bottom:8px;
  height:31px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:22px;
  z-index:4;
  font-size:14px;
}
.pager button{
  width:34px; height:29px;
  font-size:28px;
  line-height:22px;
  touch-action:manipulation;
}
.pager button:disabled{ opacity:.22; }

@media (max-width:380px){
  .notebook{ left:31px; }
  .page{ padding-left:17px; padding-right:12px; }
  .entries{ left:17px; right:12px; }
  .tab{ min-width:58px; padding-left:10px; padding-right:10px; }
  .korean{ font-size:21px; }
  .meaning{ font-size:14px; }
}
