*{
  box-sizing:border-box;
}

:root{
  --bg-primary:#ffffff;
  --bg-secondary:#f4f8f9;
  --surface-color:rgba(31,160,174,0.08);
  --accent-color:#1fa0ae;
  --accent-hover:#146a73;
  --text-primary:#1e292b;
  --text-secondary:#4a5d60;
  --border-color:#1fa0ae;
  --glow-color:rgba(31,160,174,0.25);
}

html,body{
  margin:0;
  min-height:100%;
  font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  background:var(--bg-primary);
  color:var(--text-primary);
}

body{
  min-height:100dvh;
}

button,a{
  -webkit-tap-highlight-color:transparent;
}

.screen{
  min-height:100dvh;
  padding:
    max(14px,env(safe-area-inset-top))
    max(12px,env(safe-area-inset-right))
    max(16px,env(safe-area-inset-bottom))
    max(12px,env(safe-area-inset-left));
  background:linear-gradient(180deg,var(--bg-primary),var(--bg-secondary));
}

.app-header{
  margin:0 auto 16px;
  max-width:1000px;
  width:100%;
}

.app-banner-logo{
  display:block;
  width:min(70vw,700px);
  height:auto;
  max-width:90%;
  margin:0 auto;
  object-fit:contain;
}

/* Mobile browser: keep the banner comfortably sized inside browser chrome. */
@media(max-width:699px){
  .app-banner-logo{
    width:min(68vw,320px);
    max-width:86%;
  }
}

/* Installed mobile PWA: allow the banner to use more of the standalone viewport. */
@media(display-mode:standalone) and (max-width:699px){
  .app-banner-logo{
    width:min(84vw,390px);
    max-width:92%;
  }
}


.tool-grid{
  display:grid;
  grid-template-columns:1fr;
  gap:8px;
  max-width:1000px;
  margin:0 auto 18px;
}


.tool-button{
  width:100%;
  min-height:66px;
  display:grid;
  grid-template-columns:46px minmax(0,1fr);
  align-items:center;
  gap:12px;
  padding:8px 14px 8px 10px;
  border:1.5px solid var(--border-color);
  border-radius:12px;
  background:var(--surface-color);
  color:var(--text-primary);
  font:inherit;
  cursor:pointer;
  text-align:left;
  box-shadow:0 2px 8px var(--glow-color);
  transition:
    background-color .16s ease,
    border-color .16s ease,
    transform .08s ease,
    box-shadow .16s ease;
}

.tool-button:hover{
  background:rgba(31,160,174,0.14);
  border-color:var(--accent-hover);
  box-shadow:0 3px 10px var(--glow-color);
}

.tool-button:active{
  transform:scale(.995);
  background:rgba(31,160,174,0.18);
}

.tool-button:focus-visible{
  outline:3px solid var(--glow-color);
  outline-offset:2px;
}

.tool-icon-wrap{
  width:46px;
  height:46px;
  display:grid;
  place-items:center;
  justify-self:start;
  flex:none;
}

.tool-icon{
  display:block;
  width:38px;
  height:38px;
  object-fit:contain;
}

.tool-name{
  --tool-name-max-size:21.6;
  --tool-name-min-size:11;
  min-width:0;
  width:100%;
  font-size:clamp(1.08rem,3.8vw,1.35rem);
  font-weight:750;
  line-height:1.1;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:clip;
  overflow-wrap:normal;
  color:var(--text-primary);
}

.app-footer{
  display:grid;
  gap:9px;
  max-width:1000px;
  margin:0 auto;
}

.secondary-button,
.support-button,
.back-button{
  border-radius:11px;
  font:inherit;
  cursor:pointer;
  transition:
    background-color .16s ease,
    border-color .16s ease,
    color .16s ease;
}

.secondary-button,
.support-button{
  min-height:48px;
  padding:12px 18px;
  text-align:center;
  text-decoration:none;
  font-weight:750;
}

.secondary-button{
  border:1.5px solid var(--border-color);
  background:var(--bg-primary);
  color:var(--accent-hover);
}

.secondary-button:hover{
  background:var(--surface-color);
}

.support-button{
  border:1.5px solid var(--accent-color);
  background:var(--accent-color);
  color:#ffffff;
  box-shadow:0 2px 8px var(--glow-color);
}

.support-button:hover{
  background:var(--accent-hover);
  border-color:var(--accent-hover);
}


.sample-credit{
  max-width:1000px;
  margin:16px auto 0;
  display:grid;
  grid-template-columns:84px minmax(0,1fr);
  align-items:center;
  gap:12px;
  padding:12px 14px;
  border:1px solid rgba(31,160,174,0.35);
  border-radius:12px;
  background:var(--bg-primary);
  color:var(--text-secondary);
  box-shadow:0 2px 8px rgba(31,160,174,0.10);
}

.sample-credit-logo{
  display:block;
  width:76px;
  height:76px;
  object-fit:contain;
}

.sample-credit p{
  margin:0;
  font-size:clamp(.78rem,2.7vw,.92rem);
  line-height:1.35;
}

.sample-credit a{
  color:var(--accent-hover);
  font-weight:800;
  text-decoration:underline;
  text-underline-offset:2px;
}

.sample-credit a:hover{
  color:var(--accent-color);
}

@media(max-width:430px){
  .sample-credit{
    grid-template-columns:84px minmax(0,1fr);
    gap:10px;
    padding:10px 11px;
  }

  .sample-credit-logo{
    width:76px;
    height:76px;
  }
}



.install-help{
  position:fixed;
  inset:0;
  z-index:10000;
  display:grid;
  place-items:center;
  padding:20px;
  background:rgba(30,41,43,0.46);
}

.install-help[hidden]{
  display:none;
}

.install-help-card{
  position:relative;
  width:min(92vw,460px);
  padding:22px;
  border:1.5px solid var(--border-color);
  border-radius:14px;
  background:var(--bg-primary);
  color:var(--text-primary);
  box-shadow:0 12px 36px rgba(30,41,43,0.22);
}

.install-help-card h2{
  margin:0 32px 12px 0;
  color:var(--text-primary);
  font-size:1.3rem;
}

.install-help-card p{
  margin:8px 0;
  color:var(--text-secondary);
  line-height:1.4;
}


.update-check-button{
  width:100%;
  margin-top:14px;
}

.update-status{
  min-height:1.4em;
  margin-top:10px;
  color:var(--text-secondary);
  font-size:.9rem;
  line-height:1.35;
}

.install-help-close{
  position:absolute;
  top:9px;
  right:10px;
  width:34px;
  height:34px;
  border:1px solid var(--border-color);
  border-radius:9px;
  background:var(--bg-primary);
  color:var(--accent-hover);
  font-size:24px;
  line-height:1;
  cursor:pointer;
}

.tool-screen{
  position:fixed;
  inset:0;
  width:100%;
  height:100dvh;
  background:var(--bg-primary);
  overflow:hidden;
}

.tool-header{
  height:calc(54px + env(safe-area-inset-top));
  padding-top:env(safe-area-inset-top);
  display:grid;
  grid-template-columns:auto minmax(0,1fr);
  align-items:center;
  gap:10px;
  padding-left:max(10px,env(safe-area-inset-left));
  padding-right:max(10px,env(safe-area-inset-right));
  background:var(--bg-secondary);
  border-bottom:1px solid var(--border-color);
  color:var(--text-primary);
  box-shadow:0 2px 8px var(--glow-color);
}

.back-button{
  padding:8px 12px;
  border:1.5px solid var(--border-color);
  background:var(--bg-primary);
  color:var(--accent-hover);
  font-weight:750;
}

.back-button:hover{
  background:var(--surface-color);
}


.floating-back-button{
  position:absolute;
  z-index:50;
  right:max(10px,env(safe-area-inset-right));
  bottom:max(10px,env(safe-area-inset-bottom));
  width:44px;
  height:44px;
  display:grid;
  place-items:center;
  padding:0;
  border:1.5px solid var(--border-color);
  background:rgba(255,255,255,.92);
  color:var(--accent-hover);
  font-size:1.35rem;
  font-weight:750;
  box-shadow:0 2px 10px rgba(30,41,43,.18);
  backdrop-filter:blur(6px);
  -webkit-backdrop-filter:blur(6px);
}

.tool-title{
  text-align:center;
  padding-right:68px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  font-weight:750;
  color:var(--text-primary);
}

#appFrame{
  display:block;
  width:100%;
  height:100dvh;
  border:0;
  background:var(--bg-primary);
}

@media(min-width:700px){
.screen{
    padding-left:18px;
    padding-right:18px;
  }
.tool-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:10px;
  }

  .tool-button{
    min-height:70px;
    grid-template-columns:48px minmax(0,1fr);
    padding:8px 14px 8px 10px;
  }

  .tool-icon-wrap{
    width:48px;
    height:48px;
  }

  .tool-icon{
    width:40px;
    height:40px;
  }

  .sample-credit{
    grid-template-columns:112px minmax(0,1fr);
  }

  .sample-credit-logo{
    width:100px;
    height:100px;
  }
}
